diff --git a/.github/workflows/actions/sdt-test/action.yml b/.github/workflows/actions/sdt-test/action.yml new file mode 100644 index 00000000000..d5ff399383e --- /dev/null +++ b/.github/workflows/actions/sdt-test/action.yml @@ -0,0 +1,78 @@ +# Copyright 2024 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. + +name: SDT Test + +description: SDT Test + +inputs: + check-name: + description: 'Job/Check Name' + required: true + project-dir: + description: 'Project directory' + required: true + test-name: + description: 'SDT Test Name' + required: true + +runs: + using: "composite" + steps: + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: zulu + server-id: ossrh + server-username: CI_DEPLOY_USERNAME + server-password: CI_DEPLOY_PASSWORD + + - name: Check Java version + run: java -version + shell: bash + + - name: Build repository + run: mvn -B -e -pl ${{ inputs.project-dir }} clean install -am -DskipTests=true + shell: bash + + - name: Run SDT Test + run: mvn -B -e -pl ${{ inputs.project-dir }} test -Dtest=${{ inputs.test-name }} + shell: bash + + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results + path: ${{ inputs.project-dir }}/target/surefire-reports/*.xml + + - name: Publish Test Results + uses: mikepenz/action-junit-report@v4 + if: always() + with: + report_paths: '${{ inputs.project-dir }}/target/surefire-reports/*.xml' + fail_on_failure: true + summary: true + detailed_summary: true + include_passed: true + check_name: ${{ inputs.check-name }} + job_name: ${{ inputs.check-name }} + + - name: Upload CI Event + if: always() + uses: actions/upload-artifact@v4 + with: + name: event-file + path: ${{ github.event_path }} diff --git a/.github/workflows/sdt-duckdb.yml b/.github/workflows/sdt-duckdb.yml new file mode 100644 index 00000000000..3f2ce13ee08 --- /dev/null +++ b/.github/workflows/sdt-duckdb.yml @@ -0,0 +1,36 @@ +# Copyright 2024 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. + +name: (SDT) DuckDB SQL Dialect Tests + +on: [push, pull_request] + +env: + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: SDT Test + uses: ./.github/workflows/actions/sdt-test + with: + check-name: DuckDB SDT Report + project-dir: legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure + test-name: Test_DuckDB_SDT diff --git a/.github/workflows/sdt-postgres.yml b/.github/workflows/sdt-postgres.yml new file mode 100644 index 00000000000..3afc0892fd8 --- /dev/null +++ b/.github/workflows/sdt-postgres.yml @@ -0,0 +1,36 @@ +# Copyright 2024 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. + +name: (SDT) Postgres SQL Dialect Tests + +on: [push, pull_request] + +env: + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: SDT Test + uses: ./.github/workflows/actions/sdt-test + with: + check-name: Postgres SDT Report + project-dir: legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure + test-name: Test_Postgres_SDT diff --git a/docs/compiler/compiler-extension-processor.md b/docs/compiler/compiler-extension-processor.md new file mode 100644 index 00000000000..cd0e787d7c7 --- /dev/null +++ b/docs/compiler/compiler-extension-processor.md @@ -0,0 +1,76 @@ +# Defining Compiler Extension Processor + +``` JAVA +public static Processor newProcessor( + Class elementClass, + Collection> prerequisiteClasses, + BiFunction firstPass, + BiConsumer secondPass, + BiConsumer thirdPass, + BiFunction> prerequisiteElementsPass) +``` + +## Element Class +Provide subclass of `PackageableElement` which is being compiled (e.g. `Database.class`). + +## Prerequisite Classes +Provide a set of prerequisite classes which your element class depends on (e.g. `[Mapping.class, PackageableConnection.class]`). +The compiler sorts the dependencies based on these prerequisite classes and guarantees all elements in those classes are compiled before the elements in your class. + +## First Pass +Define a function that performs the following operations: +* Create `Pure (M3)` objects and register them in Pure graph +* Set primitive values in the `Pure (M3)` objects +* **MUST NOT** reference other elements in the Pure graph + +## Second Pass +Define a function that performs the following operations: +* Resolve content of its own element and references to other elements +* **MUST NOT** introspect content of other elements or check validity/correctness + +## Third Pass +Define a function that performs the following operations: +* Resolve cross-dependencies +* Introspect other elements + +## Prerequisite Elements Pass +Define a function that returns the prerequisite elements under the same element class that your element depends on. +The compiler sorts the dependencies based on these prerequisite elements and guarantees that those elements are compiled before your element. +For instance, `MappingA` depends on `MappingB` and `MappingC`, and therefore, `MappingB` and `MappingC` must be compiled first. + +The compiler throws an `EngineException` if it finds circular dependencies in these elements. The following Pure grammar demonstrates an example of circular dependencies: + +``` pure +###Relational +Database store::CovidDataStoreA +( + include store::CovidDataStoreB +) + +Database store::CovidDataStoreB +( + include store::CovidDataStoreC +) + +Database store::CovidDataStoreC +( + include store::CovidDataStoreA + + Table DEMOGRAPHICS + ( + FIPS VARCHAR(200), + STATE VARCHAR(200) + ) + Table COVID_DATA + ( + ID INTEGER PRIMARY KEY, + FIPS VARCHAR(200), + DATE DATE, + CASE_TYPE VARCHAR(200), + CASES INTEGER, + LAST_REPORTED_FLAG BIT + ) + + Join CovidDataDemographicsJoin(DEMOGRAPHICS.FIPS = COVID_DATA.FIPS) +) +``` \ No newline at end of file diff --git a/legend-engine-application-query/pom.xml b/legend-engine-application-query/pom.xml index d37fff9b9a9..b9169d81b0a 100644 --- a/legend-engine-application-query/pom.xml +++ b/legend-engine-application-query/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-application-query diff --git a/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/api/ApplicationQuery.java b/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/api/ApplicationQuery.java index fadb62d53f4..26de6a5607a 100644 --- a/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/api/ApplicationQuery.java +++ b/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/api/ApplicationQuery.java @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.eclipse.collections.api.list.MutableList; +import org.finos.legend.engine.application.query.model.DataCubeQuery; import org.finos.legend.engine.application.query.model.Query; import org.finos.legend.engine.application.query.model.QueryEvent; import org.finos.legend.engine.application.query.model.QuerySearchSpecification; @@ -32,15 +33,7 @@ import org.pac4j.core.profile.ProfileManager; import org.pac4j.jax.rs.annotations.Pac4JProfileManager; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; @@ -51,10 +44,12 @@ public class ApplicationQuery { private final QueryStoreManager queryStoreManager; + private final DataCubeQueryStoreManager dataCubeQueryStoreManager; public ApplicationQuery(MongoClient mongoClient) { this.queryStoreManager = new QueryStoreManager(mongoClient); + this.dataCubeQueryStoreManager = new DataCubeQueryStoreManager(mongoClient); } private static String getCurrentUser(ProfileManager profileManager) @@ -255,4 +250,132 @@ public Response getQueryEvents(@QueryParam("queryId") @ApiParam("The query ID th return ExceptionTool.exceptionManager(e, LoggingEventType.GET_QUERY_EVENTS_ERROR, null); } } + + + @POST + @Path("dataCube/search") + @ApiOperation(value = "Search DataCube queries") + @Consumes({MediaType.APPLICATION_JSON}) + public Response searchDataCubeQueries(QuerySearchSpecification searchSpecification, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager profileManager) + { + try + { + return Response.ok().entity(this.dataCubeQueryStoreManager.searchQueries(searchSpecification, getCurrentUser(profileManager))).build(); + } + catch (Exception e) + { + if (e instanceof ApplicationQueryException) + { + return ((ApplicationQueryException) e).toResponse(); + } + return ExceptionTool.exceptionManager(e, LoggingEventType.SEARCH_QUERIES_ERROR, null); + } + } + + @GET + @Path("dataCube/batch") + @ApiOperation(value = "Get the DataCube queries with specified IDs") + @Consumes({MediaType.APPLICATION_JSON}) + public Response getDataCubeQueries(@QueryParam("queryIds") @ApiParam("The list of query IDs to fetch (must contain no more than 50 items)") List queryIds) + { + try + { + return Response.ok(this.dataCubeQueryStoreManager.getQueries(queryIds)).build(); + } + catch (Exception e) + { + if (e instanceof ApplicationQueryException) + { + return ((ApplicationQueryException) e).toResponse(); + } + return ExceptionTool.exceptionManager(e, LoggingEventType.GET_QUERIES_ERROR, null); + } + } + + @GET + @Path("dataCube/{queryId}") + @ApiOperation(value = "Get the DataCube query with specified ID") + @Consumes({MediaType.APPLICATION_JSON}) + public Response getDataCubeQuery(@PathParam("queryId") String queryId) + { + try + { + return Response.ok(this.dataCubeQueryStoreManager.getQuery(queryId)).build(); + } + catch (Exception e) + { + if (e instanceof ApplicationQueryException) + { + return ((ApplicationQueryException) e).toResponse(); + } + return ExceptionTool.exceptionManager(e, LoggingEventType.GET_QUERY_ERROR, null); + } + } + + @POST + @Path("dataCube") + @ApiOperation(value = "Create a new DataCube query") + @Consumes({MediaType.APPLICATION_JSON}) + public Response createDataCubeQuery(DataCubeQuery query, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager profileManager) + { + MutableList profiles = ProfileManagerHelper.extractProfiles(profileManager); + Identity identity = Identity.makeIdentity(profiles); + try + { + return Response.ok().entity(this.dataCubeQueryStoreManager.createQuery(query, getCurrentUser(profileManager))).build(); + } + catch (Exception e) + { + if (e instanceof ApplicationQueryException) + { + return ((ApplicationQueryException) e).toResponse(); + } + return ExceptionTool.exceptionManager(e, LoggingEventType.CREATE_QUERY_ERROR, identity.getName()); + } + } + + @PUT + @Path("dataCube/{queryId}") + @ApiOperation(value = "Update DataCube query") + @Consumes({MediaType.APPLICATION_JSON}) + public Response updateDataCubeQuery(@PathParam("queryId") String queryId, DataCubeQuery query, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager profileManager) + { + MutableList profiles = ProfileManagerHelper.extractProfiles(profileManager); + Identity identity = Identity.makeIdentity(profiles); + try + { + return Response.ok().entity(this.dataCubeQueryStoreManager.updateQuery(queryId, query, getCurrentUser(profileManager))).build(); + } + catch (Exception e) + { + if (e instanceof ApplicationQueryException) + { + return ((ApplicationQueryException) e).toResponse(); + } + return ExceptionTool.exceptionManager(e, LoggingEventType.UPDATE_QUERY_ERROR, identity.getName()); + } + } + + @DELETE + @Path("dataCube/{queryId}") + @ApiOperation(value = "Delete the DataCube query with specified ID") + @Consumes({MediaType.APPLICATION_JSON}) + public Response deleteDataCubeQuery(@PathParam("queryId") String queryId, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager profileManager) + { + MutableList profiles = ProfileManagerHelper.extractProfiles(profileManager); + Identity identity = Identity.makeIdentity(profiles); + try + { + this.dataCubeQueryStoreManager.deleteQuery(queryId, getCurrentUser(profileManager)); + return Response.noContent().build(); + } + catch (Exception e) + { + if (e instanceof ApplicationQueryException) + { + return ((ApplicationQueryException) e).toResponse(); + } + return ExceptionTool.exceptionManager(e, LoggingEventType.DELETE_QUERY_ERROR, identity.getName()); + } + } } diff --git a/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/api/DataCubeQueryStoreManager.java b/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/api/DataCubeQueryStoreManager.java new file mode 100644 index 00000000000..0cee796f942 --- /dev/null +++ b/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/api/DataCubeQueryStoreManager.java @@ -0,0 +1,308 @@ +// Copyright 2020 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. + +package org.finos.legend.engine.application.query.api; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mongodb.client.AggregateIterable; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.model.*; +import org.bson.Document; +import org.bson.conversions.Bson; +import org.eclipse.collections.api.factory.SortedSets; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.api.set.sorted.MutableSortedSet; +import org.eclipse.collections.impl.utility.LazyIterate; +import org.finos.legend.engine.application.query.model.DataCubeQuery; +import org.finos.legend.engine.application.query.model.QuerySearchSortBy; +import org.finos.legend.engine.application.query.model.QuerySearchSpecification; +import org.finos.legend.engine.application.query.model.QuerySearchTermSpecification; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; +import org.finos.legend.engine.shared.core.vault.Vault; + +import javax.ws.rs.core.Response; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +public class DataCubeQueryStoreManager +{ + private static final int MAX_NUMBER_OF_QUERIES = 100; + + private final ObjectMapper objectMapper = new ObjectMapper(); + private static final Document EMPTY_FILTER = Document.parse("{}"); + + private static final List LIGHT_QUERY_PROJECTION = Arrays.asList("id", "name", "createdAt", "lastUpdatedAt", "lastOpenAt"); + private static final int GET_QUERIES_LIMIT = 50; + + private final MongoClient mongoClient; + + public DataCubeQueryStoreManager(MongoClient mongoClient) + { + this.mongoClient = mongoClient; + } + + private MongoDatabase getDataCubeQueryDatabase() + { + if (Vault.INSTANCE.hasValue("query.mongo.database")) + { + return this.mongoClient.getDatabase(Vault.INSTANCE.getValue("query.mongo.database")); + } + throw new RuntimeException("DataCube Query MongoDB database has not been configured properly"); + } + + private MongoCollection getQueryCollection() + { + if (Vault.INSTANCE.hasValue("query.mongo.collection.dataCube")) + { + return this.getDataCubeQueryDatabase().getCollection(Vault.INSTANCE.getValue("query.mongo.collection.dataCube")); + } + throw new RuntimeException("DataCube Query MongoDB collection has not been configured properly"); + } + + private T documentToClass(Document document, Class _class) + { + try + { + return this.objectMapper.convertValue(document, _class); + } + catch (Exception e) + { + throw new ApplicationQueryException("Unable to deserialize document to class '" + _class.getName() + "':" + e.getMessage(), Response.Status.NOT_FOUND); + } + } + + private DataCubeQuery documentToQuery(Document document) + { + return this.documentToClass(document, DataCubeQuery.class); + } + + private Document queryToDocument(DataCubeQuery query) throws JsonProcessingException + { + return Document.parse(objectMapper.writeValueAsString(query)); + } + + private static void validate(boolean predicate, String message) + { + if (!predicate) + { + throw new ApplicationQueryException(message, Response.Status.BAD_REQUEST); + } + } + + private static void validateNonEmptyQueryField(String fieldValue, String message) + { + validate(fieldValue != null && !fieldValue.isEmpty(), message); + } + + private static void validateNonNullQueryField(Object fieldValue, String message) + { + validate(fieldValue != null, message); + } + + public static void validateQuery(DataCubeQuery query) + { + validateNonEmptyQueryField(query.id, "Query ID is missing or empty"); + validateNonEmptyQueryField(query.name, "Query name is missing or empty"); + validateNonNullQueryField(query.query, "Query is missing"); + validateNonNullQueryField(query.source, "Query source is missing"); + } + + public List searchQueries(QuerySearchSpecification searchSpecification, String currentUser) + { + List filters = new ArrayList<>(); + if (searchSpecification.searchTermSpecification != null) + { + QuerySearchTermSpecification querySearchTermSpecification = searchSpecification.searchTermSpecification; + if (querySearchTermSpecification.searchTerm == null) + { + throw new ApplicationQueryException("Query search spec expecting a search term", Response.Status.INTERNAL_SERVER_ERROR); + } + if (querySearchTermSpecification.exactMatchName != null && querySearchTermSpecification.exactMatchName) + { + Bson filter = Filters.eq("name", querySearchTermSpecification.searchTerm); + filters.add(filter); + } + else + { + Bson idFilter = Filters.eq("id", querySearchTermSpecification.searchTerm); + Bson nameFilter = Filters.regex("name", Pattern.quote(querySearchTermSpecification.searchTerm), "i"); + Bson filter = Filters.or(idFilter, nameFilter); + filters.add(filter); + } + } + + List queries = new ArrayList<>(); + List aggregateLists = new ArrayList<>(); + aggregateLists.add(Aggregates.match(filters.isEmpty() ? EMPTY_FILTER : Filters.and(filters))); + if (searchSpecification.sortByOption != null) + { + aggregateLists.add(Aggregates.sort(Sorts.descending(getSortByField(searchSpecification.sortByOption)))); + } + aggregateLists.add(Aggregates.project(Projections.include(LIGHT_QUERY_PROJECTION))); + aggregateLists.add(Aggregates.limit(Math.min(MAX_NUMBER_OF_QUERIES, searchSpecification.limit == null ? Integer.MAX_VALUE : searchSpecification.limit))); + AggregateIterable documents = this.getQueryCollection() + .aggregate(aggregateLists); + + for (Document doc : documents) + { + queries.add(documentToQuery(doc)); + } + return queries; + } + + public String getSortByField(QuerySearchSortBy sortBy) + { + switch (sortBy) + { + case SORT_BY_CREATE: + { + return "createdAt"; + } + case SORT_BY_VIEW: + { + return "lastOpenAt"; + } + case SORT_BY_UPDATE: + { + return "lastUpdatedAt"; + } + default: + { + throw new EngineException("Unknown sort-by value", EngineErrorType.COMPILATION); + } + } + } + + public List getQueries(List queryIds) + { + if (queryIds.size() > GET_QUERIES_LIMIT) + { + throw new ApplicationQueryException("Can't fetch more than " + GET_QUERIES_LIMIT + " queries", Response.Status.BAD_REQUEST); + } + MutableList matchingQueries = LazyIterate.collect(this.getQueryCollection().find(Filters.in("id", queryIds)).limit(GET_QUERIES_LIMIT), this::documentToQuery).toList(); + // validate + MutableSortedSet notFoundQueries = SortedSets.mutable.empty(); + MutableSortedSet duplicatedQueries = SortedSets.mutable.empty(); + queryIds.forEach(queryId -> + { + int count = matchingQueries.count(query -> queryId.equals(query.id)); + if (count > 1) + { + duplicatedQueries.add(queryId); + } + else if (count == 0) + { + notFoundQueries.add(queryId); + } + }); + if (!duplicatedQueries.isEmpty()) + { + throw new IllegalStateException(duplicatedQueries.makeString("Found multiple queries with duplicated ID for the following ID(s):\\n", "\\n", "")); + } + if (!notFoundQueries.isEmpty()) + { + throw new ApplicationQueryException(notFoundQueries.makeString("Can't find queries for the following ID(s):\\n", "\\n", ""), Response.Status.INTERNAL_SERVER_ERROR); + } + return matchingQueries; + } + + public DataCubeQuery getQuery(String queryId) throws JsonProcessingException + { + List matchingQueries = LazyIterate.collect(this.getQueryCollection().find(Filters.eq("id", queryId)), this::documentToQuery).toList(); + if (matchingQueries.size() > 1) + { + throw new IllegalStateException("Found multiple queries with ID '" + queryId + "'"); + } + else if (matchingQueries.isEmpty()) + { + throw new ApplicationQueryException("Can't find query with ID '" + queryId + "'", Response.Status.NOT_FOUND); + } + DataCubeQuery query = matchingQueries.get(0); + query.lastOpenAt = Instant.now().toEpochMilli(); + this.getQueryCollection().updateOne( + Filters.eq("id", queryId), + Updates.set("lastOpenAt", Instant.now().toEpochMilli()) + ); + return query; + } + + + public DataCubeQuery createQuery(DataCubeQuery query, String currentUser) throws JsonProcessingException + { + validateQuery(query); + // TODO: store ownership information + + List matchingQueries = LazyIterate.collect(this.getQueryCollection().find(Filters.eq("id", query.id)), this::documentToQuery).toList(); + if (!matchingQueries.isEmpty()) + { + throw new ApplicationQueryException("Query with ID '" + query.id + "' already existed", Response.Status.BAD_REQUEST); + } + query.createdAt = Instant.now().toEpochMilli(); + query.lastUpdatedAt = query.createdAt; + query.lastOpenAt = query.createdAt; + this.getQueryCollection().insertOne(queryToDocument(query)); + return query; + } + + public DataCubeQuery updateQuery(String queryId, DataCubeQuery query, String currentUser) throws JsonProcessingException + { + validateQuery(query); + + List matchingQueries = LazyIterate.collect(this.getQueryCollection().find(Filters.eq("id", queryId)), this::documentToQuery).toList(); + if (!queryId.equals(query.id)) + { + throw new ApplicationQueryException("Updating query ID is not supported", Response.Status.BAD_REQUEST); + } + if (matchingQueries.size() > 1) + { + throw new IllegalStateException("Found multiple queries with ID '" + queryId + "'"); + } + else if (matchingQueries.isEmpty()) + { + throw new ApplicationQueryException("Can't find query with ID '" + queryId + "'", Response.Status.NOT_FOUND); + } + DataCubeQuery currentQuery = matchingQueries.get(0); + + // TODO: check ownership + query.createdAt = currentQuery.createdAt; + query.lastUpdatedAt = Instant.now().toEpochMilli(); + query.lastOpenAt = Instant.now().toEpochMilli(); + this.getQueryCollection().findOneAndReplace(Filters.eq("id", queryId), queryToDocument(query)); + return query; + } + + public void deleteQuery(String queryId, String currentUser) throws JsonProcessingException + { + List matchingQueries = LazyIterate.collect(this.getQueryCollection().find(Filters.eq("id", queryId)), this::documentToQuery).toList(); + if (matchingQueries.size() > 1) + { + throw new IllegalStateException("Found multiple queries with ID '" + queryId + "'"); + } + else if (matchingQueries.isEmpty()) + { + throw new ApplicationQueryException("Can't find query with ID '" + queryId + "'", Response.Status.NOT_FOUND); + } + DataCubeQuery currentQuery = matchingQueries.get(0); + + // TODO: check ownership + this.getQueryCollection().findOneAndDelete(Filters.eq("id", queryId)); + } +} diff --git a/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/model/DataCubeQuery.java b/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/model/DataCubeQuery.java new file mode 100644 index 00000000000..dd277601d85 --- /dev/null +++ b/legend-engine-application-query/src/main/java/org/finos/legend/engine/application/query/model/DataCubeQuery.java @@ -0,0 +1,36 @@ +// Copyright 2020 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. + +package org.finos.legend.engine.application.query.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Map; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DataCubeQuery +{ + public String id; + public String name; + public String description; + + public Map query; + public Map source; + + public Long lastUpdatedAt; + public Long createdAt; + public Long lastOpenAt; + + // TODO: ownership +} diff --git a/legend-engine-application-query/src/test/java/org/finos/legend/engine/application/query/api/TestDataCubeQueryStoreManager.java b/legend-engine-application-query/src/test/java/org/finos/legend/engine/application/query/api/TestDataCubeQueryStoreManager.java new file mode 100644 index 00000000000..5660f64c7a5 --- /dev/null +++ b/legend-engine-application-query/src/test/java/org/finos/legend/engine/application/query/api/TestDataCubeQueryStoreManager.java @@ -0,0 +1,388 @@ +// Copyright 2020 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. + +package org.finos.legend.engine.application.query.api; + +import org.eclipse.collections.api.block.function.Function0; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Maps; +import org.finos.legend.engine.application.query.model.DataCubeQuery; +import org.finos.legend.engine.application.query.model.QuerySearchSortBy; +import org.finos.legend.engine.application.query.model.QuerySearchSpecification; +import org.finos.legend.engine.application.query.model.QuerySearchTermSpecification; +import org.finos.legend.engine.application.query.utils.TestMongoClientProvider; +import org.finos.legend.engine.shared.core.vault.TestVaultImplementation; +import org.finos.legend.engine.shared.core.vault.Vault; +import org.junit.*; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class TestDataCubeQueryStoreManager +{ + static class TestDataCubeQuerySearchSpecificationBuilder + { + public QuerySearchTermSpecification searchTermSpecification; + public Integer limit; + public Boolean showCurrentUserQueriesOnly; + public QuerySearchSortBy sortByOption; + + TestDataCubeQuerySearchSpecificationBuilder withSearchTerm(String searchTerm) + { + if (this.searchTermSpecification == null) + { + this.searchTermSpecification = new QuerySearchTermSpecification(); + } + this.searchTermSpecification.searchTerm = searchTerm; + return this; + } + + TestDataCubeQuerySearchSpecificationBuilder withLimit(Integer limit) + { + this.limit = limit; + return this; + } + + TestDataCubeQuerySearchSpecificationBuilder withShowCurrentUserQueriesOnly(Boolean showCurrentUserQueriesOnly) + { + this.showCurrentUserQueriesOnly = showCurrentUserQueriesOnly; + return this; + } + + TestDataCubeQuerySearchSpecificationBuilder withExactNameSearch(Boolean exactMatchName) + { + if (this.searchTermSpecification == null) + { + this.searchTermSpecification = new QuerySearchTermSpecification(); + } + this.searchTermSpecification.exactMatchName = exactMatchName; + return this; + } + + TestDataCubeQuerySearchSpecificationBuilder withSortByOption(QuerySearchSortBy sortByOption) + { + this.sortByOption = sortByOption; + return this; + } + + QuerySearchSpecification build() + { + QuerySearchSpecification searchSpecification = new QuerySearchSpecification(); + searchSpecification.searchTermSpecification = this.searchTermSpecification; + searchSpecification.limit = this.limit; + searchSpecification.showCurrentUserQueriesOnly = this.showCurrentUserQueriesOnly; + searchSpecification.sortByOption = this.sortByOption; + return searchSpecification; + } + } + + static class TestQueryBuilder + { + public String id; + public String name; + public String description = "description"; + public Map query = Maps.mutable.empty(); + public Map source = Maps.mutable.empty(); + + static TestQueryBuilder create(String id, String name) + { + TestQueryBuilder queryBuilder = new TestQueryBuilder(); + queryBuilder.id = id; + queryBuilder.name = name; + return queryBuilder; + } + + DataCubeQuery build() + { + DataCubeQuery query = new DataCubeQuery(); + query.id = this.id; + query.name = this.name; + query.description = this.description; + query.query = this.query; + query.source = this.source; + return query; + } + } + + private TestMongoClientProvider testMongoClientProvider = new TestMongoClientProvider(); + private final DataCubeQueryStoreManager storeManager = new DataCubeQueryStoreManager(testMongoClientProvider.mongoClient); + private static final TestVaultImplementation testVaultImplementation = new TestVaultImplementation(); + + @BeforeClass + public static void setupClass() + { + testVaultImplementation.setValue("query.mongo.database", "test"); + testVaultImplementation.setValue("query.mongo.collection.dataCube", "dataCube"); + Vault.INSTANCE.registerImplementation(testVaultImplementation); + } + + @AfterClass + public static void cleanUpClass() + { + Vault.INSTANCE.unregisterImplementation(testVaultImplementation); + } + + @Before + public void setup() + { + this.testMongoClientProvider = new TestMongoClientProvider(); + } + + @After + public void cleanUp() + { + this.testMongoClientProvider.cleanUp(); + } + + @Test + public void testValidateQuery() + { + Function0 _createTestQuery = () -> TestQueryBuilder.create("1", "query1").build(); + DataCubeQuery goodQuery = _createTestQuery.get(); + DataCubeQueryStoreManager.validateQuery(goodQuery); + + // ID + DataCubeQuery queryWithInvalidId = _createTestQuery.get(); + queryWithInvalidId.id = null; + Assert.assertEquals("Query ID is missing or empty", Assert.assertThrows(ApplicationQueryException.class, () -> DataCubeQueryStoreManager.validateQuery(queryWithInvalidId)).getMessage()); + queryWithInvalidId.id = ""; + Assert.assertEquals("Query ID is missing or empty", Assert.assertThrows(ApplicationQueryException.class, () -> DataCubeQueryStoreManager.validateQuery(queryWithInvalidId)).getMessage()); + + // Name + DataCubeQuery queryWithInvalidName = _createTestQuery.get(); + queryWithInvalidName.name = null; + Assert.assertEquals("Query name is missing or empty", Assert.assertThrows(ApplicationQueryException.class, () -> DataCubeQueryStoreManager.validateQuery(queryWithInvalidName)).getMessage()); + queryWithInvalidId.name = ""; + Assert.assertEquals("Query name is missing or empty", Assert.assertThrows(ApplicationQueryException.class, () -> DataCubeQueryStoreManager.validateQuery(queryWithInvalidName)).getMessage()); + + // TODO?: validate content + } + + @Test + public void testSearchQueries() throws Exception + { + String currentUser = "testUser"; + DataCubeQuery newQuery = TestQueryBuilder.create("1", "query1").build(); + storeManager.createQuery(newQuery, currentUser); + List queries = storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().build(), currentUser); + Assert.assertEquals(1, queries.size()); + DataCubeQuery lightQuery = queries.get(0); + Assert.assertEquals("1", lightQuery.id); + Assert.assertEquals("query1", lightQuery.name); + Assert.assertNotNull(lightQuery.createdAt); + Assert.assertNotNull(lightQuery.lastUpdatedAt); + Assert.assertNull(lightQuery.description); + } + + @Test + public void testMatchExactNameQuery() throws Exception + { + String currentUser = "testUser"; + DataCubeQuery newQuery = TestQueryBuilder.create("1", "Test Query 1").build(); + DataCubeQuery newQueryTwo = TestQueryBuilder.create("2", "Test Query 12").build(); + DataCubeQuery newQueryThree = TestQueryBuilder.create("3", "Test Query 13").build(); + storeManager.createQuery(newQuery, currentUser); + storeManager.createQuery(newQueryTwo, currentUser); + storeManager.createQuery(newQueryThree, currentUser); + List queriesGeneralSearch = storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSearchTerm("Test Query 1").build(), currentUser); + Assert.assertEquals(3, queriesGeneralSearch.size()); + List queriesExactSearch = storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSearchTerm("Test Query 1").withExactNameSearch(true).build(), currentUser); + Assert.assertEquals(1, queriesExactSearch.size()); + } + + @Test + public void testGetQueriesWithLimit() throws Exception + { + String currentUser = "testUser"; + storeManager.createQuery(TestQueryBuilder.create("1", "query1").build(), currentUser); + storeManager.createQuery(TestQueryBuilder.create("2", "query2").build(), currentUser); + Assert.assertEquals(1, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withLimit(1).build(), currentUser).size()); + Assert.assertEquals(2, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().build(), currentUser).size()); + Assert.assertEquals(0, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withLimit(0).build(), currentUser).size()); + } + + @Test + public void testGetQueriesWithSortBy() throws Exception + { + String currentUser = "testUser"; + DataCubeQuery testQuery1 = TestQueryBuilder.create("1", "query1").build(); + DataCubeQuery testQuery2 = TestQueryBuilder.create("2", "query2").build(); + DataCubeQuery testQuery3 = TestQueryBuilder.create("3", "query3").build(); + DataCubeQuery testQuery4 = TestQueryBuilder.create("4", "query4").build(); + + // create in order 1 -> 4 -> 2 -> 3 + storeManager.createQuery(testQuery1, currentUser); + Thread.sleep(100); + storeManager.createQuery(testQuery4, currentUser); + Thread.sleep(100); + storeManager.createQuery(testQuery2, currentUser); + Thread.sleep(100); + storeManager.createQuery(testQuery3, currentUser); + + Assert.assertEquals(4, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSortByOption(QuerySearchSortBy.SORT_BY_CREATE).build(), currentUser).size()); + Assert.assertEquals(Arrays.asList("3", "2", "4", "1"), storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSortByOption(QuerySearchSortBy.SORT_BY_CREATE).build(), currentUser).stream().map(q -> q.id).collect(Collectors.toList())); + + storeManager.updateQuery("2", TestQueryBuilder.create("2", "query2NewlyUpdated").build(), currentUser); + Assert.assertEquals(Arrays.asList("2", "3", "4", "1"), storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSortByOption(QuerySearchSortBy.SORT_BY_UPDATE).build(), currentUser).stream().map(q -> q.id).collect(Collectors.toList())); + + storeManager.getQuery("1"); + Assert.assertEquals(Arrays.asList("1", "2", "3", "4"), storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSortByOption(QuerySearchSortBy.SORT_BY_VIEW).build(), currentUser).stream().map(q -> q.id).collect(Collectors.toList())); + } + + @Test + public void testGetQueriesWithSearchText() throws Exception + { + String currentUser = "testUser"; + storeManager.createQuery(TestQueryBuilder.create("1", "query1").build(), currentUser); + storeManager.createQuery(TestQueryBuilder.create("2", "query2").build(), currentUser); + storeManager.createQuery(TestQueryBuilder.create("3", "query2").build(), currentUser); + Assert.assertEquals(3, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().build(), currentUser).size()); + Assert.assertEquals(1, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSearchTerm("query1").build(), currentUser).size()); + Assert.assertEquals(2, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSearchTerm("query2").build(), currentUser).size()); + Assert.assertEquals(3, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSearchTerm("query").build(), currentUser).size()); + } + + @Test + public void testGetNotFoundQuery() + { + Assert.assertEquals("Can't find query with ID '1'", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.getQuery("1")).getMessage()); + } + + @Test + public void testCreateSimpleQuery() throws Exception + { + String currentUser = "testUser"; + DataCubeQuery newQuery = TestQueryBuilder.create("1", "query1").build(); + DataCubeQuery createdQuery = storeManager.createQuery(newQuery, currentUser); + Assert.assertEquals("1", createdQuery.id); + Assert.assertEquals("query1", createdQuery.name); + Assert.assertEquals("description", createdQuery.description); + Assert.assertNotNull(createdQuery.createdAt); + Assert.assertEquals(createdQuery.createdAt, createdQuery.lastUpdatedAt); + Assert.assertEquals(createdQuery.lastOpenAt, createdQuery.lastUpdatedAt); + } + + @Test + public void testCreateInvalidQuery() + { + String currentUser = "testUser"; + Assert.assertEquals("Query name is missing or empty", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.createQuery(TestQueryBuilder.create("1", null).build(), currentUser)).getMessage()); + } + + @Test + public void testCreateQueryWithSameId() throws Exception + { + String currentUser = "testUser"; + storeManager.createQuery(TestQueryBuilder.create("1", "query1").build(), currentUser); + Assert.assertEquals("Query with ID '1' already existed", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.createQuery(TestQueryBuilder.create("1", "query1").build(), currentUser)).getMessage()); + } + + @Test + public void testUpdateQuery() throws Exception + { + String currentUser = "testUser"; + storeManager.createQuery(TestQueryBuilder.create("1", "query1").build(), currentUser); + storeManager.updateQuery("1", TestQueryBuilder.create("1", "query2").build(), currentUser); + Assert.assertEquals("query2", storeManager.getQuery("1").name); + } + + @Test + public void testUpdateWithInvalidQuery() + { + String currentUser = "testUser"; + Assert.assertEquals("Query name is missing or empty", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.updateQuery("1", TestQueryBuilder.create("1", null).build(), currentUser)).getMessage()); + } + + @Test + public void testUpdateNotFoundQuery() + { + String currentUser = "testUser"; + Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.updateQuery("1", TestQueryBuilder.create("1", "query1").build(), currentUser)); + } + + @Test + public void testDeleteQuery() throws Exception + { + String currentUser = "testUser"; + storeManager.createQuery(TestQueryBuilder.create("1", "query1").build(), currentUser); + storeManager.deleteQuery("1", currentUser); + Assert.assertEquals(0, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().build(), currentUser).size()); + } + + @Test + public void testDeleteNotFoundQuery() + { + String currentUser = "testUser"; + Assert.assertEquals("Can't find query with ID '1'", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.deleteQuery("1", currentUser)).getMessage()); + } + + @Test + public void testCreateSimpleQueryContainsTimestamps() throws Exception + { + String currentUser = "testUser"; + DataCubeQuery newQuery = TestQueryBuilder.create("1", "query1").build(); + DataCubeQuery createdQuery = storeManager.createQuery(newQuery, currentUser); + Assert.assertNotNull(createdQuery.lastUpdatedAt); + Assert.assertNotNull(createdQuery.createdAt); + } + + @Test + public void testSearchQueriesContainTimestamps() throws Exception + { + String currentUser = "testUser"; + DataCubeQuery newQuery = TestQueryBuilder.create("1", "query1").build(); + storeManager.createQuery(newQuery, currentUser); + List queries = storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().build(), currentUser); + Assert.assertEquals(1, queries.size()); + DataCubeQuery lightQuery = queries.get(0); + Assert.assertNotNull(lightQuery.lastUpdatedAt); + Assert.assertNotNull(lightQuery.createdAt); + } + + @Test + public void testSearchQueriesWithSearchByQueryId() throws Exception + { + String currentUser = "testUser"; + storeManager.createQuery(TestQueryBuilder.create("26929514-237c-11ed-861d-0242ac120002", "query_a").build(), currentUser); + storeManager.createQuery(TestQueryBuilder.create("26929515-237c-11bd-851d-0243ac120002", "query_b").build(), currentUser); + storeManager.createQuery(TestQueryBuilder.create("23929515-235c-11ad-851d-0143ac120002", "query_c").build(), currentUser); + Assert.assertEquals(3, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().build(), currentUser).size()); + Assert.assertEquals(1, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSearchTerm("23929515-235c-11ad-851d-0143ac120002").build(), currentUser).size()); + Assert.assertEquals(0, storeManager.searchQueries(new TestDataCubeQuerySearchSpecificationBuilder().withSearchTerm("23929515-235c-11ad").build(), currentUser).size()); + } + + @Test + public void testGetQueries() throws Exception + { + String currentUser = "testUser"; + DataCubeQuery testQuery1 = TestQueryBuilder.create("1", "query1").build(); + DataCubeQuery testQuery2 = TestQueryBuilder.create("2", "query2").build(); + DataCubeQuery testQuery3 = TestQueryBuilder.create("3", "query3").build(); + storeManager.createQuery(testQuery1, currentUser); + storeManager.createQuery(testQuery2, currentUser); + storeManager.createQuery(testQuery3, currentUser); + + Assert.assertEquals(1, storeManager.getQueries(Lists.fixedSize.of("2")).size()); + Assert.assertEquals(1, storeManager.getQueries(Lists.fixedSize.of("3")).size()); + Assert.assertEquals(2, storeManager.getQueries(Lists.fixedSize.of("2", "3")).size()); + + Assert.assertEquals("Can't find queries for the following ID(s):\\n4", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.getQueries(Lists.fixedSize.of("4"))).getMessage()); + Assert.assertEquals("Can't find queries for the following ID(s):\\n4\\n6", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.getQueries(Lists.fixedSize.of("4", "3", "6"))).getMessage()); + + Assert.assertEquals("Can't fetch more than 50 queries", Assert.assertThrows(ApplicationQueryException.class, () -> storeManager.getQueries(Lists.fixedSize.ofAll(Collections.nCopies(51, "5")))).getMessage()); + } +} diff --git a/legend-engine-config/legend-engine-configuration/legend-engine-configuration-contract-extension-pure/pom.xml b/legend-engine-config/legend-engine-configuration/legend-engine-configuration-contract-extension-pure/pom.xml index f18b545a8f9..461592909c7 100644 --- a/legend-engine-config/legend-engine-configuration/legend-engine-configuration-contract-extension-pure/pom.xml +++ b/legend-engine-config/legend-engine-configuration/legend-engine-configuration-contract-extension-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-configuration - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-configuration-contract-extension-pure diff --git a/legend-engine-config/legend-engine-configuration/legend-engine-configuration-plan-generation-serialization/pom.xml b/legend-engine-config/legend-engine-configuration/legend-engine-configuration-plan-generation-serialization/pom.xml index 17801a81bed..2e91ba77747 100644 --- a/legend-engine-config/legend-engine-configuration/legend-engine-configuration-plan-generation-serialization/pom.xml +++ b/legend-engine-config/legend-engine-configuration/legend-engine-configuration-plan-generation-serialization/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-configuration - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-configuration-plan-generation-serialization diff --git a/legend-engine-config/legend-engine-configuration/pom.xml b/legend-engine-config/legend-engine-configuration/pom.xml index 3eccdeaebd4..460d7c4c57e 100644 --- a/legend-engine-config/legend-engine-configuration/pom.xml +++ b/legend-engine-config/legend-engine-configuration/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-config - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-config/legend-engine-extensions-collection-execution/pom.xml b/legend-engine-config/legend-engine-extensions-collection-execution/pom.xml index a0c4690196f..2116e40206b 100644 --- a/legend-engine-config/legend-engine-extensions-collection-execution/pom.xml +++ b/legend-engine-config/legend-engine-extensions-collection-execution/pom.xml @@ -19,7 +19,7 @@ legend-engine-config org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-config/legend-engine-extensions-collection-generation/pom.xml b/legend-engine-config/legend-engine-extensions-collection-generation/pom.xml index 30db6739033..0d2b2662ee1 100644 --- a/legend-engine-config/legend-engine-extensions-collection-generation/pom.xml +++ b/legend-engine-config/legend-engine-extensions-collection-generation/pom.xml @@ -19,7 +19,7 @@ legend-engine-config org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -78,7 +78,10 @@ org.finos.legend.engine legend-engine-identity-core - + + org.finos.legend.engine + legend-engine-xt-functionActivator-grammar + org.finos.legend.engine legend-engine-executionPlan-generation @@ -353,6 +356,11 @@ legend-engine-xt-relationalStore-sqlDialectTranslation-pure runtime + + org.finos.legend.engine + legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure + runtime + diff --git a/legend-engine-config/legend-engine-extensions-collection-generation/src/test/java/org/finos/legend/engine/extensions/collection/generation/TestExtensions.java b/legend-engine-config/legend-engine-extensions-collection-generation/src/test/java/org/finos/legend/engine/extensions/collection/generation/TestExtensions.java index a95c7297ba0..7daf1743fde 100644 --- a/legend-engine-config/legend-engine-extensions-collection-generation/src/test/java/org/finos/legend/engine/extensions/collection/generation/TestExtensions.java +++ b/legend-engine-config/legend-engine-extensions-collection-generation/src/test/java/org/finos/legend/engine/extensions/collection/generation/TestExtensions.java @@ -44,6 +44,7 @@ import org.finos.legend.engine.language.hostedService.grammar.to.HostedServiceGrammarComposer; import org.finos.legend.engine.language.memsqlFunction.grammar.from.MemSqlFunctionGrammarParserExtension; import org.finos.legend.engine.language.memsqlFunction.grammar.to.MemSqlFunctionGrammarComposer; +import org.finos.legend.engine.language.functionActivator.grammar.postDeployment.to.PostDeploymentActionGrammarComposer; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; import org.finos.legend.engine.language.pure.dsl.authentication.grammar.from.AuthenticationGrammarParserExtension; @@ -378,6 +379,7 @@ protected Iterable> getE .with(DataSpaceGrammarComposerExtension.class) .with(SnowflakeAppGrammarComposer.class) .with(HostedServiceGrammarComposer.class) + .with(PostDeploymentActionGrammarComposer.class) .with(BigQueryFunctionGrammarComposer.class) .with(MemSqlFunctionGrammarComposer.class) .with(DiagramGrammarComposerExtension.class) @@ -416,6 +418,17 @@ protected Iterable> getExpectedComp .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.DataSpaceCompilerExtension.class) .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.TextCompilerExtension.class) .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.CoreCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.ProfileCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.EnumerationCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.ClassCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.MeasureCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.AssociationCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.FunctionCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.MappingCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableRuntimeCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableConnectionCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.SectionIndexCompilerExtension.class) + .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.DataElementCompilerExtension.class) .with(org.finos.legend.engine.language.pure.dsl.generation.compiler.toPureGraph.GenerationCompilerExtensionImpl.class) .with(org.finos.legend.engine.language.pure.dsl.service.compiler.toPureGraph.ServiceCompilerExtensionImpl.class) .with(org.finos.legend.engine.language.pure.compiler.toPureGraph.ExternalFormatCompilerExtension.class) @@ -584,6 +597,8 @@ protected Iterable getExpectedCodeRepositories() .with("core_nonrelational_mongodb_java_platform_binding") .with("core_external_store_relational_sql_planning") .with("core_external_store_relational_sql_dialect_translation") + .with("core_external_store_relational_sql_dialect_translation_duckdb") + .with("core_external_store_relational_postgres_sql_parser") ; } } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-app-assembly/pom.xml b/legend-engine-config/legend-engine-repl/legend-engine-repl-app-assembly/pom.xml index 7ad3985910c..c00c43d4c61 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-app-assembly/pom.xml +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-app-assembly/pom.xml @@ -21,7 +21,7 @@ org.finos.legend.engine legend-engine-repl - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-repl-app-assembly diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/pom.xml b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/pom.xml index c2dad7cd393..b062d7483f6 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/pom.xml +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/pom.xml @@ -19,7 +19,7 @@ legend-engine-repl org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/client/Client.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/client/Client.java index e4d88fc94ee..53011f092d7 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/client/Client.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/client/Client.java @@ -95,11 +95,10 @@ public Client(MutableList replExtensions, MutableList e.initialize(this)); - replExtensions.forEach(e -> e.postInitialize(this)); this.printDebug("[DEV] Legend REPL v" + DeploymentStateAndVersions.sdlc.buildVersion + " (" + DeploymentStateAndVersions.sdlc.commitIdAbbreviated + ")"); if (System.getProperty("legend.repl.initializationMessage") != null) @@ -122,9 +121,7 @@ public Client(MutableList replExtensions, MutableList replExtensions, MutableList e.postInitialize(this)); + + this.println("Warming up..."); + this.terminal.flush(); + ((Execute) this.commands.getLast()).execute("1+1"); + this.println("Ready!\n"); + } + catch (Exception exception) + { + this.printError("Failed to initialize REPL. Error:\n" + exception.getMessage()); + // NOTE: we let people continue even if the warm-up failed, in order to let them + // debug the issue or take some measures to recover + } } private void initialize() diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/ReplExtension.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/ReplExtension.java index 6f2350c3332..558afe726d2 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/ReplExtension.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/ReplExtension.java @@ -52,7 +52,7 @@ default void initialize(Client client) { } - // This method is called after all extensions have been initialized + // This method is called after all extensions and the client have been initialized. // This is useful for cases where we need to invoke initialization-type tasks from one extension // that might depend on another extension. This is for now the preferred approach over specifying // a dependency graph to determine the order of initialization. diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/commands/Doc.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/commands/Doc.java index 93e966f4bb7..b28f244d3f9 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/commands/Doc.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-client/src/main/java/org/finos/legend/engine/repl/core/commands/Doc.java @@ -14,9 +14,13 @@ package org.finos.legend.engine.repl.core.commands; +import org.eclipse.collections.api.factory.Maps; +import org.eclipse.collections.api.factory.Sets; import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.repl.client.Client; +import org.finos.legend.engine.repl.client.jline3.JLine3Parser; import org.finos.legend.engine.repl.core.Command; import org.finos.legend.engine.repl.shared.DocumentationHelper; import org.finos.legend.pure.m3.pct.aggregate.model.FunctionDocumentation; @@ -24,34 +28,52 @@ import org.jline.reader.LineReader; import org.jline.reader.ParsedLine; +import java.util.List; +import java.util.Map; + public class Doc implements Command { private final Client client; + private final DocGroupCompleter completer; + private final Map functionDocIndex = Maps.mutable.empty(); public Doc(Client client) { this.client = client; + this.client.getDocumentedFunctions().forEach(key -> + { + FunctionDocumentation doc = this.client.getFunctionDocumentation(key); + String path = doc.functionDefinition.sourceId.substring(doc.reportScope.filePath.length(), doc.functionDefinition.sourceId.lastIndexOf(".pure")); + functionDocIndex.put(path, doc); + }); + this.completer = new DocGroupCompleter(functionDocIndex); } @Override public String documentation() { - return "doc "; + return "doc () | docFn "; } @Override public String description() { - return "show documentation of the specified Pure function"; + return "'doc' command supports browsing all supported Pure functions\n" + + "'docFn' command shows documentation of the specified Pure function"; } @Override public boolean process(String line) throws Exception { - if (line.startsWith("doc")) + if (line.startsWith("docFn")) { String[] tokens = line.split(" "); - String path = tokens[1]; + String path = tokens.length > 1 ? tokens[1] : ""; + if (path.isEmpty()) + { + client.printError("Function path is required"); + return true; + } FunctionDocumentation functionDocumentation = this.client.getFunctionDocumentation(path); if (functionDocumentation != null) { @@ -63,16 +85,84 @@ public boolean process(String line) throws Exception } return true; } + else if (line.startsWith("doc")) + { + String[] tokens = line.split(" "); + String path = tokens.length > 1 ? tokens[1] : ""; + if (path.isEmpty()) + { + client.printError("Function path is required"); + return true; + } + FunctionDocumentation functionDocumentation = this.functionDocIndex.get(path); + if (functionDocumentation != null) + { + client.println(DocumentationHelper.generateANSIFunctionDocumentation(functionDocumentation, client.getDocumentationAdapterKeys())); + } + else + { + client.printError("No documentation found for function: " + path); + } + return true; + } return false; } @Override public MutableList complete(String inScope, LineReader lineReader, ParsedLine parsedLine) { - if (inScope.startsWith("doc")) + if (inScope.startsWith("docFn")) { return ListIterate.collect(client.getDocumentedFunctions(), Candidate::new); } + else if (inScope.startsWith("doc")) + { + MutableList words = Lists.mutable.withAll(parsedLine.words()).drop(2); + String path = words.makeString(""); + MutableList list = Lists.mutable.empty(); + completer.complete(lineReader, new JLine3Parser.MyParsedLine(new JLine3Parser.ParserResult(parsedLine.line(), Lists.mutable.with("doc", " ", path))), list); + return list; + } return null; } + + private static class DocGroupCompleter implements org.jline.reader.Completer + { + private final Map functionDocIndex; + + public DocGroupCompleter(Map functionDocIndex) + { + this.functionDocIndex = functionDocIndex; + } + + public void complete(LineReader reader, ParsedLine commandLine, final List candidates) + { + String buffer = commandLine.word().substring(0, commandLine.wordCursor()); + String current; + String sep = "/"; + int lastSep = buffer.lastIndexOf(sep); + try + { + current = lastSep >= 0 ? buffer.substring(0, lastSep + 1) : ""; + Sets.mutable.withAll(functionDocIndex.keySet()) + .select(path -> path.startsWith(current)) + .collect(path -> + { + String childNode = path.substring(current.length()); + return current + childNode.substring(0, !childNode.contains(sep) ? childNode.length() : childNode.indexOf(sep) + 1); + }) + .toSortedList() + .forEach(value -> + { + candidates.add(value.endsWith(sep) + ? new Candidate(value, sep + value, null, null, "/", null, false) + : new Candidate(value, value, null, null, null, null, true)); + }); + } + catch (Exception e) + { + // Ignore + } + } + } } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/pom.xml b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/pom.xml index a2edc86d401..f76176801a4 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/pom.xml +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/pom.xml @@ -19,7 +19,7 @@ legend-engine-repl org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -203,18 +203,10 @@ eclipse-collections-api - - com.fasterxml.jackson.core - jackson-core - com.fasterxml.jackson.core jackson-databind - - com.fasterxml.jackson.core - jackson-annotations - org.jline diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCubeWalkthrough.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCubeWalkthrough.java index 6f5a1125edf..4e34d065cc7 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCubeWalkthrough.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCubeWalkthrough.java @@ -304,11 +304,11 @@ protected MutableList> getSteps() "history with ArrowUp/Down key, etc."))); this.println(""); this.println(wrap("The function documentation lookup tool can be quite helpful, for example, to view documentation and " + - "usages for 'filter', use the following command:")); - this.printCommand("doc meta::pure::functions::relation::filter"); + "usages for function 'filter', use the following command:")); + this.printCommand("doc collection/iteration/filter"); this.println(ansiDim(printRule(null))); this.println(DocumentationHelper.generateANSIFunctionDocumentation(this.client.getFunctionDocumentation("meta::pure::functions::relation::filter"), this.client.getDocumentationAdapterKeys())); - this.client.addCommandToHistory("doc meta::pure::functions::relation::filter"); + this.client.addCommandToHistory("doc collection/iteration/filter"); this.println(ansiDim(printRule(null))); this.println(""); this.println(wrap("Also, don't forget to hit the 'Tab' key while typing up an expression, the compiler can help validate " + diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java index d354ba7af1f..f85cd75da61 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java @@ -29,7 +29,7 @@ import java.sql.Statement; import java.util.List; -import static org.finos.legend.engine.repl.relational.shared.ResultHelper.prettyGridPrint; +import static org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResultGridPrintUtility.prettyGridPrint; public class DataCube__DEV__runDuckDBSelectSQL implements Command { diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/DataCubeHelpers.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/DataCubeHelpers.java index 3a7542c1cf3..6c802da0fa4 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/DataCubeHelpers.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/DataCubeHelpers.java @@ -35,6 +35,7 @@ import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity; import org.finos.legend.engine.protocol.pure.v1.model.relationType.RelationType; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda; @@ -50,6 +51,7 @@ import org.finos.legend.engine.shared.core.kerberos.SubjectTools; import org.finos.legend.pure.generated.Root_meta_pure_executionPlan_ExecutionPlan; import org.finos.legend.pure.generated.Root_meta_pure_extension_Extension; +import org.finos.legend.pure.m3.navigation.M3Paths; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -125,6 +127,20 @@ public static DataCubeExecutionResult executeQuery(Client client, LegendInterfac } } + public static RelationType getRelationReturnType(LegendInterface legendInterface, Lambda lambda, PureModelContextData data) + { + PureModelContextData pmcd; + if (data != null) + { + pmcd = DataCubeHelpers.injectNewFunction(data, lambda).getOne(); + } + else + { + pmcd = PureModelContextData.newBuilder().withElement(wrapLambda(lambda)).build(); + } + return getRelationReturnType(legendInterface, pmcd); + } + public static RelationType getRelationReturnType(LegendInterface legendInterface, PureModelContextData data) { PureModel pureModel = legendInterface.compile(data); @@ -141,16 +157,21 @@ public static String getQueryCode(ValueSpecification valueSpecification, Boolean return valueSpecification.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().withRenderStyle(pretty != null && pretty ? RenderStyle.PRETTY : RenderStyle.STANDARD).build()); } - public static CompletionResult getCodeTypeahead(String code, String baseQueryCode, PureModelContextData data, MutableList extensions, LegendInterface legendInterface) + public static CompletionResult getCodeTypeahead(String code, Lambda lambda, PureModelContextData data, MutableList extensions, LegendInterface legendInterface) { try { - PureModelContextData newData = PureModelContextData.newBuilder() - .withOrigin(data.getOrigin()) - .withSerializer(data.getSerializer()) - .withElements(ListIterate.select(data.getElements(), el -> !el.getPath().equals(REPL_RUN_FUNCTION_QUALIFIED_PATH))) - .build(); - String graphCode = PureGrammarComposer.newInstance(PureGrammarComposerContext.Builder.newInstance().build()).renderPureModelContextData(newData); + String graphCode = ""; + if (data != null) + { + PureModelContextData newData = PureModelContextData.newBuilder() + .withOrigin(data.getOrigin()) + .withSerializer(data.getSerializer()) + .withElements(ListIterate.select(data.getElements(), el -> !el.getPath().equals(REPL_RUN_FUNCTION_QUALIFIED_PATH))) + .build(); + graphCode = PureGrammarComposer.newInstance(PureGrammarComposerContext.Builder.newInstance().build()).renderPureModelContextData(newData); + } + String baseQueryCode = lambda != null ? getQueryCode(lambda.body.get(0), false) : null; String queryCode = (baseQueryCode != null ? baseQueryCode : "") + code; Completer completer = new Completer(graphCode, extensions, legendInterface); CompletionResult result = completer.complete(queryCode); @@ -166,6 +187,17 @@ public static CompletionResult getCodeTypeahead(String code, String baseQueryCod } } + public static Function wrapLambda(Lambda lambda) + { + Function func = new Function(); + func.name = REPL_RUN_FUNCTION_QUALIFIED_PATH.substring(REPL_RUN_FUNCTION_QUALIFIED_PATH.lastIndexOf("::") + 2); + func._package = REPL_RUN_FUNCTION_QUALIFIED_PATH.substring(0, REPL_RUN_FUNCTION_QUALIFIED_PATH.lastIndexOf("::")); + func.returnType = M3Paths.Any; + func.returnMultiplicity = new Multiplicity(0, null); + func.body = lambda.body; + return func; + } + /** * Replace the magic function in the given graph data by a new function with the body of the specified lambda */ diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServer.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServer.java index b72b2bd6f22..9ffcb8ffe1a 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServer.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServer.java @@ -81,9 +81,9 @@ public void initialize() throws Exception .withKeyValue("/repl/", new DataCubeInfrastructure.StaticContent()) .withKeyValue("/api/dataCube/infrastructureInfo", new DataCubeInfrastructure.GridLicenseKey()) .withKeyValue("/api/dataCube/typeahead", new DataCubeQueryBuilder.QueryTypeahead()) - .withKeyValue("/api/dataCube/parseQuery", new DataCubeQueryBuilder.ParseQuery()) - .withKeyValue("/api/dataCube/getQueryCode", new DataCubeQueryBuilder.GetQueryCode()) - .withKeyValue("/api/dataCube/getQueryCode/batch", new DataCubeQueryBuilder.GetQueryCodeBatch()) + .withKeyValue("/api/dataCube/parseValueSpecification", new DataCubeQueryBuilder.ParseValueSpecification()) + .withKeyValue("/api/dataCube/getValueSpecificationCode", new DataCubeQueryBuilder.GetValueSpecificationCode()) + .withKeyValue("/api/dataCube/getValueSpecificationCode/batch", new DataCubeQueryBuilder.GetValueSpecificationCodeBatch()) .withKeyValue("/api/dataCube/getBaseQuery", new DataCubeQueryBuilder.GetBaseQuery()) .withKeyValue("/api/dataCube/getRelationReturnType", new DataCubeQueryBuilder.GetRelationReturnType()) .withKeyValue("/api/dataCube/getRelationReturnType/code", new DataCubeQueryBuilder.GetQueryCodeRelationReturnType()) diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServerHelpers.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServerHelpers.java index 1dda19d267c..78f0ec301cc 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServerHelpers.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/REPLServerHelpers.java @@ -20,6 +20,7 @@ import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; @@ -41,7 +42,6 @@ import org.finos.legend.engine.repl.core.legend.LegendInterface; import org.finos.legend.engine.repl.dataCube.server.model.DataCubeQuery; import org.finos.legend.engine.repl.dataCube.server.model.DataCubeQueryColumn; -import org.finos.legend.engine.repl.dataCube.server.model.DataCubeQuerySourceREPLExecutedQuery; import org.finos.legend.engine.repl.shared.ExecutionHelper; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relation.RelationType; import org.finos.legend.pure.m3.navigation.M3Paths; @@ -49,7 +49,10 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.Deque; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import static org.finos.legend.engine.repl.shared.ExecutionHelper.REPL_RUN_FUNCTION_QUALIFIED_PATH; @@ -71,29 +74,6 @@ public static void handleResponse(HttpExchange exchange, int responseCode, Strin } } - public static Map getQueryParams(HttpExchange exchange) - { - String query = exchange.getRequestURI().getQuery(); - Map result = new HashMap<>(); - if (query == null) - { - return result; - } - for (String param : query.split("&")) - { - String[] entry = param.split("="); - if (entry.length > 1) - { - result.put(entry[0], entry[1]); - } - else - { - result.put(entry[0], ""); - } - } - return result; - } - public static class REPLServerState { public final Client client; @@ -104,6 +84,7 @@ public static class REPLServerState private PureModelContextData currentPureModelContextData; private DataCubeQuery query; + private Map source; public REPLServerState(Client client, ObjectMapper objectMapper, PlanExecutor planExecutor, LegendInterface legendInterface) { @@ -116,16 +97,9 @@ public REPLServerState(Client client, ObjectMapper objectMapper, PlanExecutor pl private void initialize(PureModelContextData pureModelContextData, List columns) { this.currentPureModelContextData = pureModelContextData; - this.startTime = System.currentTimeMillis(); - this.query = new DataCubeQuery(); - this.query.name = "New Report"; - this.query.configuration = null; // initially, the config is not initialized - - // process source - DataCubeQuerySourceREPLExecutedQuery source = new DataCubeQuerySourceREPLExecutedQuery(); - source.columns = columns; + // -------------------- SOURCE -------------------- // try to extract the runtime for the query // remove any usage of multiple from(), only add one to the end // TODO: we might need to account for other variants of ->from(), such as when mapping is specified @@ -173,33 +147,30 @@ else if (fn.parameters.size() == 3) fn.parameters.set(0, currentExpression); currentExpression = fn; } + Map source = Maps.mutable.empty(); + source.put("_type", "repl"); + source.put("timestamp", this.startTime); + source.put("query", currentExpression.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().build())); + source.put("runtime", runtime); + source.put("mapping", mapping); + this.source = source; - this.query.partialQuery = ""; - source.query = currentExpression.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().build()); - source.runtime = runtime; - source.mapping = mapping; - this.query.source = source; - - // build the partial query + // -------------------- QUERY -------------------- + DataCubeQuery query = new DataCubeQuery(); + query.configuration = null; // initially, the config is not initialized // NOTE: for this, the initial query is going to be a select all AppliedFunction partialFn = new AppliedFunction(); partialFn.function = "select"; ColSpecArray colSpecArray = new ColSpecArray(); - colSpecArray.colSpecs = ListIterate.collect(source.columns, col -> + colSpecArray.colSpecs = ListIterate.collect(columns, col -> { ColSpec colSpec = new ColSpec(); colSpec.name = col.name; return colSpec; }); partialFn.parameters = Lists.mutable.with(new ClassInstance("colSpecArray", colSpecArray, null)); - this.query.partialQuery = partialFn.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().build()); - - // build the full query - AppliedFunction fullFn = new AppliedFunction(); - fullFn.function = "from"; - fullFn.parameters = mapping != null ? Lists.mutable.with(partialFn, new PackageableElementPtr(mapping), new PackageableElementPtr(runtime)) : Lists.mutable.with(partialFn, new PackageableElementPtr(runtime)); - partialFn.parameters = Lists.mutable.with(currentExpression).withAll(partialFn.parameters); - this.query.query = fullFn.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().build()); + query.query = partialFn.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().build()); + this.query = query; } public void initializeFromTable(PureModelContextData pureModelContextData) @@ -270,6 +241,11 @@ public DataCubeQuery getQuery() { return this.query; } + + public Map getSource() + { + return this.source; + } } public interface DataCubeServerHandler diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/handler/DataCubeQueryBuilder.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/handler/DataCubeQueryBuilder.java index e516c8bb579..94833b616a0 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/handler/DataCubeQueryBuilder.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/handler/DataCubeQueryBuilder.java @@ -25,7 +25,6 @@ import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.protocol.pure.v1.model.relationType.RelationType; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification; -import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda; import org.finos.legend.engine.repl.autocomplete.CompletionResult; import org.finos.legend.engine.repl.dataCube.server.DataCubeHelpers; import org.finos.legend.engine.repl.dataCube.server.model.*; @@ -34,6 +33,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.Map; import java.util.stream.Collectors; import static org.finos.legend.engine.repl.dataCube.server.REPLServerHelpers.*; @@ -42,7 +42,7 @@ public class DataCubeQueryBuilder { - public static class ParseQuery implements DataCubeServerHandler + public static class ParseValueSpecification implements DataCubeServerHandler { @Override public HttpHandler getHandler(REPLServerState state) @@ -69,7 +69,7 @@ public HttpHandler getHandler(REPLServerState state) } } - public static class GetQueryCode implements DataCubeServerHandler + public static class GetValueSpecificationCode implements DataCubeServerHandler { @Override public HttpHandler getHandler(REPLServerState state) @@ -83,8 +83,8 @@ public HttpHandler getHandler(REPLServerState state) InputStreamReader inputStreamReader = new InputStreamReader(exchange.getRequestBody(), StandardCharsets.UTF_8); BufferedReader bufferReader = new BufferedReader(inputStreamReader); String requestBody = bufferReader.lines().collect(Collectors.joining()); - DataCubeGetQueryCodeInput input = state.objectMapper.readValue(requestBody, DataCubeGetQueryCodeInput.class); - handleResponse(exchange, 200, DataCubeHelpers.getQueryCode(input.query, input.pretty), state); + DataCubeGetValueSpecificationCodeInput input = state.objectMapper.readValue(requestBody, DataCubeGetValueSpecificationCodeInput.class); + handleResponse(exchange, 200, DataCubeHelpers.getQueryCode(input.value, input.pretty), state); } catch (Exception e) { @@ -95,7 +95,7 @@ public HttpHandler getHandler(REPLServerState state) } } - public static class GetQueryCodeBatch implements DataCubeServerHandler + public static class GetValueSpecificationCodeBatch implements DataCubeServerHandler { @Override public HttpHandler getHandler(REPLServerState state) @@ -109,9 +109,9 @@ public HttpHandler getHandler(REPLServerState state) InputStreamReader inputStreamReader = new InputStreamReader(exchange.getRequestBody(), StandardCharsets.UTF_8); BufferedReader bufferReader = new BufferedReader(inputStreamReader); String requestBody = bufferReader.lines().collect(Collectors.joining()); - DataCubeGetQueryCodeBatchInput input = state.objectMapper.readValue(requestBody, DataCubeGetQueryCodeBatchInput.class); + DataCubeGetValueSpecificationCodeBatchInput input = state.objectMapper.readValue(requestBody, DataCubeGetValueSpecificationCodeBatchInput.class); DataCubeGetQueryCodeBatchResult result = new DataCubeGetQueryCodeBatchResult(); - MapAdapter.adapt(input.queries).forEachKeyValue((key, value) -> + MapAdapter.adapt(input.values).forEachKeyValue((key, value) -> { try { @@ -148,8 +148,7 @@ public HttpHandler getHandler(REPLServerState state) BufferedReader bufferReader = new BufferedReader(inputStreamReader); String requestBody = bufferReader.lines().collect(Collectors.joining()); DataCubeQueryTypeaheadInput input = state.objectMapper.readValue(requestBody, DataCubeQueryTypeaheadInput.class); - PureModelContextData data = state.getCurrentPureModelContextData(); - CompletionResult result = DataCubeHelpers.getCodeTypeahead(input.code, DataCubeHelpers.getQueryCode(input.baseQuery, false), data, state.client.getCompleterExtensions(), state.legendInterface); + CompletionResult result = DataCubeHelpers.getCodeTypeahead(input.code, input.baseQuery, input.isolated ? null : state.getCurrentPureModelContextData(), state.client.getCompleterExtensions(), state.legendInterface); handleResponse(exchange, 200, state.objectMapper.writeValueAsString(result.getCompletion()), state); } catch (Exception e) @@ -176,9 +175,7 @@ public HttpHandler getHandler(REPLServerState state) BufferedReader bufferReader = new BufferedReader(inputStreamReader); String requestBody = bufferReader.lines().collect(Collectors.joining()); DataCubeGetQueryRelationReturnTypeInput input = state.objectMapper.readValue(requestBody, DataCubeGetQueryRelationReturnTypeInput.class); - Lambda lambda = input.query; // if no lambda is specified, we're executing the initial query - PureModelContextData data = DataCubeHelpers.injectNewFunction(state.getCurrentPureModelContextData(), lambda).getOne(); - handleResponse(exchange, 200, state.objectMapper.writeValueAsString(DataCubeHelpers.getRelationReturnType(state.legendInterface, data)), state); + handleResponse(exchange, 200, state.objectMapper.writeValueAsString(DataCubeHelpers.getRelationReturnType(state.legendInterface, input.query, input.isolated ? null : state.getCurrentPureModelContextData())), state); } catch (Exception e) { @@ -204,17 +201,21 @@ public HttpHandler getHandler(REPLServerState state) BufferedReader bufferReader = new BufferedReader(inputStreamReader); String requestBody = bufferReader.lines().collect(Collectors.joining()); DataCubeGetQueryCodeRelationReturnTypeInput input = state.objectMapper.readValue(requestBody, DataCubeGetQueryCodeRelationReturnTypeInput.class); - PureModelContextData currentData = state.getCurrentPureModelContextData(); - PureModelContextData newData = PureModelContextData.newBuilder() - .withOrigin(currentData.getOrigin()) - .withSerializer(currentData.getSerializer()) - .withElements(ListIterate.select(currentData.getElements(), el -> !el.getPath().equals(REPL_RUN_FUNCTION_QUALIFIED_PATH))) - .build(); - String graphCode = PureGrammarComposer.newInstance(PureGrammarComposerContext.Builder.newInstance().build()).renderPureModelContextData(newData); - graphCode += "\n###Pure\n" + - "import meta::pure::functions::relation::*;\n" + - "function " + REPL_RUN_FUNCTION_SIGNATURE + "{\n"; - graphCode += DataCubeHelpers.getQueryCode(input.baseQuery, false) + "\n"; + + String graphCode = ""; + if (!input.isolated) + { + PureModelContextData currentData = state.getCurrentPureModelContextData(); + PureModelContextData newData = PureModelContextData.newBuilder() + .withOrigin(currentData.getOrigin()) + .withSerializer(currentData.getSerializer()) + .withElements(ListIterate.select(currentData.getElements(), el -> !el.getPath().equals(REPL_RUN_FUNCTION_QUALIFIED_PATH))) + .build(); + graphCode += PureGrammarComposer.newInstance(PureGrammarComposerContext.Builder.newInstance().build()).renderPureModelContextData(newData); + graphCode += "\n###Pure\n"; + } + graphCode += "function " + REPL_RUN_FUNCTION_SIGNATURE + "{\n"; + graphCode += DataCubeHelpers.getQueryCode(input.baseQuery.body.get(0), false) + "\n"; int lineOffset = StringUtils.countMatches(graphCode, "\n"); graphCode += input.code; graphCode += "\n}"; @@ -254,13 +255,12 @@ public HttpHandler getHandler(REPLServerState state) try { DataCubeQuery query = state.getQuery(); + Map source = state.getSource(); if (query != null) { DataCubeGetBaseQueryResult result = new DataCubeGetBaseQueryResult(); - result.timestamp = state.startTime; result.query = query; - result.partialQuery = DataCubeHelpers.parseQuery(query.partialQuery, false); - result.sourceQuery = DataCubeHelpers.parseQuery(query.source.query, false); + result.source = source; handleResponse(exchange, 200, state.objectMapper.writeValueAsString(result), state); } else diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetBaseQueryResult.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetBaseQueryResult.java index ae339c4e7b8..b73ab865282 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetBaseQueryResult.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetBaseQueryResult.java @@ -14,12 +14,10 @@ package org.finos.legend.engine.repl.dataCube.server.model; -import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification; +import java.util.Map; public class DataCubeGetBaseQueryResult { public DataCubeQuery query; - public Long timestamp; - public ValueSpecification partialQuery; - public ValueSpecification sourceQuery; + public Map source; } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeRelationReturnTypeInput.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeRelationReturnTypeInput.java index 89953170266..0128dc37020 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeRelationReturnTypeInput.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeRelationReturnTypeInput.java @@ -14,10 +14,11 @@ package org.finos.legend.engine.repl.dataCube.server.model; -import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification; +import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda; public class DataCubeGetQueryCodeRelationReturnTypeInput { public String code; - public ValueSpecification baseQuery; + public Lambda baseQuery; + public Boolean isolated = false; } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryRelationReturnTypeInput.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryRelationReturnTypeInput.java index 0a8cf232538..f11209f1654 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryRelationReturnTypeInput.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryRelationReturnTypeInput.java @@ -19,4 +19,5 @@ public class DataCubeGetQueryRelationReturnTypeInput { public Lambda query; + public Boolean isolated = false; } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeBatchInput.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetValueSpecificationCodeBatchInput.java similarity index 88% rename from legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeBatchInput.java rename to legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetValueSpecificationCodeBatchInput.java index d96747e07a4..b8098cabc61 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeBatchInput.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetValueSpecificationCodeBatchInput.java @@ -18,8 +18,8 @@ import java.util.Map; -public class DataCubeGetQueryCodeBatchInput +public class DataCubeGetValueSpecificationCodeBatchInput { - public Map queries; + public Map values; public Boolean pretty; } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeInput.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetValueSpecificationCodeInput.java similarity index 89% rename from legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeInput.java rename to legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetValueSpecificationCodeInput.java index acd62d1ad38..7604ba115f3 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetQueryCodeInput.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeGetValueSpecificationCodeInput.java @@ -16,8 +16,8 @@ import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification; -public class DataCubeGetQueryCodeInput +public class DataCubeGetValueSpecificationCodeInput { - public ValueSpecification query; + public ValueSpecification value; public Boolean pretty; } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuery.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuery.java index bba8ec8481e..ec6ba099076 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuery.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuery.java @@ -14,18 +14,10 @@ package org.finos.legend.engine.repl.dataCube.server.model; -import com.fasterxml.jackson.annotation.JsonRawValue; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Map; public class DataCubeQuery { - public String name; public String query; - public String partialQuery; - public DataCubeQuerySource source; - - // NOTE: we don't need to process the config, so we will leave it as raw JSON - @JsonRawValue - @JsonDeserialize(using = DataCubeQueryConfigurationDeserializer.class) - public String configuration; + public Map configuration; } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQueryTypeaheadInput.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQueryTypeaheadInput.java index 84622e749b8..6aabda9618b 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQueryTypeaheadInput.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQueryTypeaheadInput.java @@ -14,10 +14,11 @@ package org.finos.legend.engine.repl.dataCube.server.model; -import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification; +import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda; public class DataCubeQueryTypeaheadInput { public String code; - public ValueSpecification baseQuery; + public Lambda baseQuery; + public Boolean isolated = false; } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/test/java/org/finos/legend/engine/repl/dataCube/TestDataCubeHelpers.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/test/java/org/finos/legend/engine/repl/dataCube/TestDataCubeHelpers.java index 0e882e37bf6..bc75b1db240 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/test/java/org/finos/legend/engine/repl/dataCube/TestDataCubeHelpers.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/test/java/org/finos/legend/engine/repl/dataCube/TestDataCubeHelpers.java @@ -197,7 +197,15 @@ public void testTypeaheadPartial() { String code = "->extend(~[newCol:c|'ok', colX: c|$c."; String expectedResult = "{\"completion\":[{\"completion\":\"FIRSTNAME\",\"display\":\"FIRSTNAME\"}]}"; - testTypeahead(expectedResult, code, "#>{test::TestDatabase.TEST0}#->filter(c | $c.FIRSTNAME != 'Doe')->select(~FIRSTNAME)->from(test::test)"); + testTypeahead(expectedResult, code, (Lambda) DataCubeHelpers.parseQuery("|#>{test::TestDatabase.TEST0}#->filter(c | $c.FIRSTNAME != 'Doe')->select(~FIRSTNAME)->from(test::test)", false), pureModelContextData); + } + + @Test + public void testTypeaheadPartialWithDummySource() + { + String code = "->extend(~[newCol:c|'ok', colX: c|$c."; + String expectedResult = "{\"completion\":[{\"completion\":\"FIRSTNAME\",\"display\":\"FIRSTNAME\"}]}"; + testTypeahead(expectedResult, code, (Lambda) DataCubeHelpers.parseQuery("|''->cast(@meta::pure::metamodel::relation::Relation<(FIRSTNAME:String)>)", false), null); } @Test @@ -205,7 +213,7 @@ public void testTypeaheadFull() { String code = "#>{test::TestDatabase.TEST0}#->extend(~[newCol:c|'ok', colX: c|$c."; String expectedResult = "{\"completion\":[{\"completion\":\"FIRSTNAME\",\"display\":\"FIRSTNAME\"},{\"completion\":\"LASTNAME\",\"display\":\"LASTNAME\"}]}"; - testTypeahead(expectedResult, code, null); + testTypeahead(expectedResult, code, null, pureModelContextData); } @Test @@ -213,14 +221,14 @@ public void testTypeaheadFullWithError() { String code = "#>{test::TestDatabase.TEST0}#-->extend(~[newCol:c|'ok', colX: c|$c."; String expectedResult = "{\"completion\":[]}"; - testTypeahead(expectedResult, code, null); + testTypeahead(expectedResult, code, null, pureModelContextData); } - private void testTypeahead(String expectedResult, String code, String baseQueryCode) + private void testTypeahead(String expectedResult, String code, Lambda lambda, PureModelContextData data) { try { - Assert.assertEquals(expectedResult, objectMapper.writeValueAsString(DataCubeHelpers.getCodeTypeahead(code, baseQueryCode, pureModelContextData, completerExtensions, legendInterface))); + Assert.assertEquals(expectedResult, objectMapper.writeValueAsString(DataCubeHelpers.getCodeTypeahead(code, lambda, data, completerExtensions, legendInterface))); } catch (IOException e) { @@ -233,7 +241,7 @@ public void testExtractRelationReturnTypeGroupBy() { String lambda = "|#>{test::TestDatabase.TEST0}#->filter(c | $c.FIRSTNAME != 'Doe')->groupBy(~[FIRSTNAME], ~[count: x | $x.FIRSTNAME : y | $y->count()])->from(test::test)"; String expectedResult = "{\"columns\":[{\"name\":\"FIRSTNAME\",\"type\":\"String\"},{\"name\":\"count\",\"type\":\"Integer\"}]}"; - testExtractRelationReturnType(expectedResult, lambda); + testExtractRelationReturnType(expectedResult, lambda, pureModelContextData); } @Test @@ -241,7 +249,7 @@ public void testExtractRelationReturnTypeCast() { String lambda = "|#>{test::TestDatabase.TEST0}#->filter(c | $c.FIRSTNAME != 'Doe')->from(test::test)->groupBy(~[FIRSTNAME], ~[count: x | $x.FIRSTNAME : y | $y->count()])->cast(@meta::pure::metamodel::relation::Relation<(hai:String,ba:Integer)>)"; String expectedResult = "{\"columns\":[{\"name\":\"hai\",\"type\":\"String\"},{\"name\":\"ba\",\"type\":\"Integer\"}]}"; - testExtractRelationReturnType(expectedResult, lambda); + testExtractRelationReturnType(expectedResult, lambda, pureModelContextData); } @Test @@ -249,7 +257,7 @@ public void testExtractRelationReturnTypeSimpleExtend() { String lambda = "|#>{test::TestDatabase.TEST0}#->extend(~newCol:c|'ok')"; String expectedResult = "{\"columns\":[{\"name\":\"FIRSTNAME\",\"type\":\"String\"},{\"name\":\"LASTNAME\",\"type\":\"String\"},{\"name\":\"newCol\",\"type\":\"String\"}]}"; - testExtractRelationReturnType(expectedResult, lambda); + testExtractRelationReturnType(expectedResult, lambda, pureModelContextData); } @Test @@ -257,16 +265,23 @@ public void testExtractRelationReturnTypeMultipleExtend() { String lambda = "|#>{test::TestDatabase.TEST0}#->extend(~[newCol:c|'ok', colX: c|$c.FIRSTNAME])"; String expectedResult = "{\"columns\":[{\"name\":\"FIRSTNAME\",\"type\":\"String\"},{\"name\":\"LASTNAME\",\"type\":\"String\"},{\"name\":\"newCol\",\"type\":\"String\"},{\"name\":\"colX\",\"type\":\"String\"}]}"; - testExtractRelationReturnType(expectedResult, lambda); + testExtractRelationReturnType(expectedResult, lambda, pureModelContextData); } - private void testExtractRelationReturnType(String expectedResult, String code) + @Test + public void testExtractRelationReturnTypeWithDummySource() + { + String lambda = "|''->cast(@meta::pure::metamodel::relation::Relation<(FIRSTNAME:String,LASTNAME:String)>)->extend(~[newCol:c|'ok', colX: c|$c.FIRSTNAME])"; + String expectedResult = "{\"columns\":[{\"name\":\"FIRSTNAME\",\"type\":\"String\"},{\"name\":\"LASTNAME\",\"type\":\"String\"},{\"name\":\"newCol\",\"type\":\"String\"},{\"name\":\"colX\",\"type\":\"String\"}]}"; + testExtractRelationReturnType(expectedResult, lambda, null); + } + + private void testExtractRelationReturnType(String expectedResult, String code, PureModelContextData data) { try { Lambda lambda = (Lambda) DataCubeHelpers.parseQuery(code, false); - PureModelContextData data = DataCubeHelpers.injectNewFunction(pureModelContextData, lambda).getOne(); - Assert.assertEquals(expectedResult, objectMapper.writeValueAsString(DataCubeHelpers.getRelationReturnType(legendInterface, data))); + Assert.assertEquals(expectedResult, objectMapper.writeValueAsString(DataCubeHelpers.getRelationReturnType(legendInterface, lambda, data))); } catch (IOException e) { @@ -278,23 +293,22 @@ private void testExtractRelationReturnType(String expectedResult, String code) public void testExtractRelationReturnTypeWithParserError() { String lambda = "|#>{test::TestDatabase.TEST0}#-->extend(~[newCol:c|'ok', colX: c|$c.FIRSTNAME])"; - testExtractRelationReturnTypeFailure("PARSER error at [1:31]: Unexpected token '-'. Valid alternatives: [';']", lambda); + testExtractRelationReturnTypeFailure("PARSER error at [1:31]: Unexpected token '-'. Valid alternatives: [';']", lambda, pureModelContextData); } @Test public void testExtractRelationReturnTypeWithCompilationError() { String lambda = "|#>{test::TestDatabase.TEST0}#->extend(~[newCol:c|'ok', colX: c|$c.FIRSTNAME2])"; - testExtractRelationReturnTypeFailure("COMPILATION error at [1:68-77]: The column 'FIRSTNAME2' can't be found in the relation (FIRSTNAME:String, LASTNAME:String)", lambda); + testExtractRelationReturnTypeFailure("COMPILATION error at [1:68-77]: The column 'FIRSTNAME2' can't be found in the relation (FIRSTNAME:String, LASTNAME:String)", lambda, pureModelContextData); } - private void testExtractRelationReturnTypeFailure(String errorMessage, String code) + private void testExtractRelationReturnTypeFailure(String errorMessage, String code, PureModelContextData data) { EngineException e = Assert.assertThrows(EngineException.class, () -> { Lambda lambda = (Lambda) DataCubeHelpers.parseQuery(code, true); - PureModelContextData data = DataCubeHelpers.injectNewFunction(pureModelContextData, lambda).getOne(); - DataCubeHelpers.getRelationReturnType(legendInterface, data); + DataCubeHelpers.getRelationReturnType(legendInterface, lambda, data); }); Assert.assertEquals(errorMessage, EngineException.buildPrettyErrorMessage(e.getMessage(), e.getSourceInformation(), e.getErrorType())); } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/pom.xml b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/pom.xml index 8290ea24c1f..bcebfc1acc3 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/pom.xml +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/pom.xml @@ -19,7 +19,7 @@ legend-engine-repl org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -109,11 +109,6 @@ - - com.h2database - h2 - - org.finos.legend.engine diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java index 5641ed2c348..c71e0923758 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java @@ -16,9 +16,8 @@ import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.impl.factory.Lists; -import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.plan.execution.result.Result; -import org.finos.legend.engine.plan.execution.stores.relational.AlloyH2Server; +import org.finos.legend.engine.plan.execution.stores.relational.result.RealizedRelationalResult; import org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult; import org.finos.legend.engine.repl.client.Client; import org.finos.legend.engine.repl.core.Command; @@ -30,28 +29,11 @@ import org.finos.legend.engine.repl.relational.local.LocalConnectionManagement; import org.finos.legend.engine.repl.relational.local.LocalConnectionType; -import java.sql.ResultSet; -import java.sql.SQLException; - -import static org.finos.legend.engine.repl.relational.shared.ResultHelper.prettyGridPrint; +import static org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResultGridPrintUtility.prettyGridPrint; public class RelationalReplExtension implements ReplExtension { public static String DUCKDB_LOCAL_CONNECTION_BASE_NAME = "DuckDuck"; - - static - { - try - { - int port = AlloyH2Server.startServer(0).getPort(); - System.setProperty("legend.test.h2.port", String.valueOf(port)); - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - } - private Client client; private int maxRowSize = 40; private LocalConnectionManagement localConnectionManagement; @@ -67,7 +49,6 @@ public void initialize(Client client) { this.client = client; this.localConnectionManagement = new LocalConnectionManagement(client); - // this.localConnectionManagement.addLocalConnection(LocalConnectionType.H2, "MyTestH2"); this.localConnectionManagement.addLocalConnection(LocalConnectionType.DuckDB, DUCKDB_LOCAL_CONNECTION_BASE_NAME); } @@ -91,20 +72,21 @@ public MutableList getExtraCommands() @Override public boolean supports(Result res) { - return res instanceof RelationalResult; + return res instanceof RelationalResult || res instanceof RealizedRelationalResult; } @Override public String print(Result res) { - RelationalResult relationalResult = (RelationalResult) res; - try (ResultSet rs = relationalResult.resultSet) + if (res instanceof RelationalResult) { - return prettyGridPrint(rs, relationalResult.sqlColumns, ListIterate.collect(relationalResult.getSQLResultColumns(), col -> col.dataType), maxRowSize, 60); + RelationalResult relationalResult = (RelationalResult) res; + return prettyGridPrint(relationalResult, maxRowSize, 60); } - catch (Exception e) + else { - throw new RuntimeException(e); + RealizedRelationalResult relationalResult = (RealizedRelationalResult) res; + return prettyGridPrint(relationalResult, maxRowSize, 60); } } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/commands/DB.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/commands/DB.java index ada6a2b2807..1a568ecad18 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/commands/DB.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/commands/DB.java @@ -70,7 +70,7 @@ public boolean process(String line) throws Exception try (Connection connection = ConnectionHelper.getConnection(databaseConnection, client.getPlanExecutor())) { this.client.println( - getTables(connection).collect(c -> c.schema + "." + c.name + "(" + c.columns.collect(col -> col.name + " " + col.type).makeString(", ") + ")").makeString("\n") + getTables(connection).collect(c -> c.schema + "." + c.name + "(" + c.columns.collect(col -> PureGrammarComposerUtility.convertIdentifier(col.name, true) + " " + col.type).makeString(", ") + ")").makeString("\n") ); } return true; diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/local/LocalConnectionManagement.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/local/LocalConnectionManagement.java index 531f97a52a0..e1f91c61b50 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/local/LocalConnectionManagement.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/local/LocalConnectionManagement.java @@ -74,7 +74,7 @@ public MutableList generateDynamicContent(String code) res.add("###Relational\n" + "Database local::" + conn + "Database" + "(" + - getTables(connection).collect(table -> "Table " + table.name + "(" + table.columns.collect(c -> (c.name.contains(" ") ? "\"" + c.name + "\"" : c.name) + " " + c.type).makeString(",") + ")").makeString("\n") + + getTables(connection).collect(table -> "Table " + table.name + "(" + table.columns.collect(c -> PureGrammarComposerUtility.convertIdentifier(c.name, true) + " " + c.type).makeString(",") + ")").makeString("\n") + ")\n"); } catch (SQLException e) diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/shared/ResultHelper.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/shared/ResultHelper.java deleted file mode 100644 index e349ef31d48..00000000000 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/shared/ResultHelper.java +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.repl.relational.shared; - -import org.eclipse.collections.api.block.function.Function; -import org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction; -import org.eclipse.collections.api.list.MutableList; -import org.eclipse.collections.impl.factory.Lists; - -import java.sql.ResultSet; -import java.util.List; - -public class ResultHelper -{ - public static String prettyGridPrint(ResultSet resultSet, List columnNames, List columnTypes, int maxRowSize, int maxColSize) - { - MutableList columns = Lists.mutable.empty(); - MutableList size = Lists.mutable.empty(); - MutableList> values = Lists.mutable.empty(); - - try - { - int columnCount = columnNames.size(); - - // collect data - for (int i = 0; i < columnCount; i++) - { - columns.add(columnNames.get(i)); - values.add(Lists.mutable.empty()); - } - while (resultSet.next()) - { - for (int i = 1; i <= columnCount; i++) - { - String value = resultSet.getObject(i) == null ? "" : resultSet.getObject(i).toString(); - values.get(i - 1).add(value); - } - } - - // determine the max size for each column - for (int i = 0; i < columnCount; i++) - { - size.add(values.get(i).injectInto(Math.max(columns.get(i).length(), columnTypes.get(i).length()), (IntObjectToIntFunction) (a, b) -> Math.max(b.length(), a))); - } - size = Lists.mutable.withAll(size.collect(s -> Math.min(maxColSize, s + 2))); - - // print the result - StringBuilder builder = new StringBuilder(); - - drawSeparation(builder, columnCount, size); - drawRow(builder, columnCount, size, columns::get, maxColSize); - drawRow(builder, columnCount, size, columnTypes::get, maxColSize); - drawSeparation(builder, columnCount, size); - - int rows = values.get(0).size(); - if (rows <= maxRowSize) - { - for (int k = 0; k < rows; k++) - { - final int fk = k; - drawRow(builder, columnCount, size, i -> values.get(i).get(fk), maxColSize); - } - } - else - { - int topRows = (int) Math.ceil((float) maxRowSize / 2); - int bottomRows = maxRowSize - topRows; - for (int k = 0; k < topRows; k++) - { - final int fk = k; - drawRow(builder, columnCount, size, i -> values.get(i).get(fk), maxColSize); - } - for (int k = 0; k < 3; k++) - { - drawRow(builder, columnCount, size, i -> ".", maxColSize); - } - for (int k = rows - bottomRows; k < rows; k++) - { - final int fk = k; - drawRow(builder, columnCount, size, i -> values.get(i).get(fk), maxColSize); - } - } - - - drawSeparation(builder, columnCount, size); - - // add summary - builder.append(rows + " rows " + (rows > maxRowSize ? ("(" + maxRowSize + " shown) ") : "") + "-- " + columns.size() + " columns"); - return builder.toString(); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - private static void drawSeparation(StringBuilder builder, int count, MutableList size) - { - builder.append("+"); - for (int i = 0; i < count; i++) - { - repeat('-', size.get(i), builder); - builder.append("+"); - } - builder.append("\n"); - } - - private static void repeat(char value, int length, StringBuilder builder) - { - for (int k = 0; k < length; k++) - { - builder.append(value); - } - } - - private static void drawRow(StringBuilder builder, int count, MutableList size, Function getter, int maxColSize) - { - builder.append("|"); - for (int i = 0; i < count; i++) - { - String val = printValue(getter.apply(i), maxColSize); - int space = (size.get(i) - val.length()) / 2; - repeat(' ', space, builder); - builder.append(val); - repeat(' ', size.get(i) - val.length() - space, builder); - builder.append("|"); - } - - builder.append("\n"); - } - - private static String printValue(String str, int max) - { - return str.length() >= max ? str.substring(0, max - 3 - 2) + "..." : str; - } -} diff --git a/legend-engine-config/legend-engine-repl/pom.xml b/legend-engine-config/legend-engine-repl/pom.xml index 36e5e4ac81e..349177bd2a3 100644 --- a/legend-engine-config/legend-engine-repl/pom.xml +++ b/legend-engine-config/legend-engine-repl/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-config - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-config/legend-engine-server/legend-engine-server-http-server/pom.xml b/legend-engine-config/legend-engine-server/legend-engine-server-http-server/pom.xml index 4b549b04d7d..a7cd62e96a5 100644 --- a/legend-engine-config/legend-engine-server/legend-engine-server-http-server/pom.xml +++ b/legend-engine-config/legend-engine-server/legend-engine-server-http-server/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-server - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-server-http-server diff --git a/legend-engine-config/legend-engine-server/legend-engine-server-http-server/src/test/java/org/finos/legend/engine/server/test/pureClient/stores/Test_Relational_UsingPureClientTestSuite.java b/legend-engine-config/legend-engine-server/legend-engine-server-http-server/src/test/java/org/finos/legend/engine/server/test/pureClient/stores/Test_Relational_UsingPureClientTestSuite.java index 0700509ea2d..52fddc10fa0 100644 --- a/legend-engine-config/legend-engine-server/legend-engine-server-http-server/src/test/java/org/finos/legend/engine/server/test/pureClient/stores/Test_Relational_UsingPureClientTestSuite.java +++ b/legend-engine-config/legend-engine-server/legend-engine-server-http-server/src/test/java/org/finos/legend/engine/server/test/pureClient/stores/Test_Relational_UsingPureClientTestSuite.java @@ -84,6 +84,7 @@ public static Test suite() throws Exception suite.addTest(buildSuite(TestCollection.collectTests("meta::pure::graphFetch::tests::XStoreUnion::inMemoryAndRelational", executionSupport.getProcessorSupport(), ci -> satisfiesConditions(ci, executionSupport.getProcessorSupport())), executionSupport)); suite.addTest(buildSuite(TestCollection.collectTests("meta::pure::graphFetch::tests::XStore::ordered", executionSupport.getProcessorSupport(), ci -> satisfiesConditions(ci, executionSupport.getProcessorSupport())), executionSupport)); suite.addTest(buildSuite(TestCollection.collectTests("meta::relational::tests::functions::pureToSqlQuery::calendarAggregations", executionSupport.getProcessorSupport(), ci -> satisfiesConditions(ci, executionSupport.getProcessorSupport())), executionSupport)); + suite.addTest(buildSuite(TestCollection.collectTests("meta::relational::tests::platform", executionSupport.getProcessorSupport(), ci -> satisfiesConditions(ci, executionSupport.getProcessorSupport())), executionSupport)); return suite; }, diff --git a/legend-engine-config/legend-engine-server/legend-engine-server-integration-tests/pom.xml b/legend-engine-config/legend-engine-server/legend-engine-server-integration-tests/pom.xml index 2f76932b055..a9e7d3e6632 100644 --- a/legend-engine-config/legend-engine-server/legend-engine-server-integration-tests/pom.xml +++ b/legend-engine-config/legend-engine-server/legend-engine-server-integration-tests/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-server - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-server-integration-tests diff --git a/legend-engine-config/legend-engine-server/legend-engine-server-support-core/pom.xml b/legend-engine-config/legend-engine-server/legend-engine-server-support-core/pom.xml index 30f1fffebdd..bc9332212ac 100644 --- a/legend-engine-config/legend-engine-server/legend-engine-server-support-core/pom.xml +++ b/legend-engine-config/legend-engine-server/legend-engine-server-support-core/pom.xml @@ -3,7 +3,7 @@ legend-engine-server org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-config/legend-engine-server/pom.xml b/legend-engine-config/legend-engine-server/pom.xml index acabb914ab1..9b1d1f370c1 100644 --- a/legend-engine-config/legend-engine-server/pom.xml +++ b/legend-engine-config/legend-engine-server/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-config - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-config/pom.xml b/legend-engine-config/pom.xml index 04ff2b647b1..941039a955a 100644 --- a/legend-engine-config/pom.xml +++ b/legend-engine-config/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-dependencies/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-dependencies/pom.xml index c90e8420cc7..40f5ef54122 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-dependencies/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-dependencies/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-executionPlan-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-executionPlan-dependencies diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-authorizer/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-authorizer/pom.xml index 860804c98d4..c6f8e6e60e9 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-authorizer/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-authorizer/pom.xml @@ -3,7 +3,7 @@ legend-engine-core-executionPlan-execution org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-http-api/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-http-api/pom.xml index 342799de8e1..45125626b0c 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-executionPlan-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-executionPlan-execution-http-api diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-store-inMemory/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-store-inMemory/pom.xml index 862a46d87c6..ec93d482083 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-store-inMemory/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution-store-inMemory/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-executionPlan-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-executionPlan-execution-store-inMemory diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/pom.xml index ca17c005510..d4d31e54154 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-executionPlan-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-executionPlan-execution diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java index f750b4509cc..86d39bca21a 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java @@ -368,7 +368,7 @@ public ExecutionState buildDefaultExecutionState(SingleExecutionPlan executionPl return buildDefaultExecutionState(executionPlan, vars, null); } - private ExecutionState buildDefaultExecutionState(SingleExecutionPlan executionPlan, Map vars, PlanExecutionContext planExecutionContext) + public ExecutionState buildDefaultExecutionState(SingleExecutionPlan executionPlan, Map vars, PlanExecutionContext planExecutionContext) { ExecutionState executionState = new ExecutionState(vars, executionPlan.templateFunctions, this.extraExecutors.collect(StoreExecutor::buildStoreExecutionState), this.isJavaCompilationAllowed, null, this.graphFetchExecutionConfiguration, this.logSQLWithParamValues); diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/nodes/helpers/platform/DefaultExecutionNodeContext.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/nodes/helpers/platform/DefaultExecutionNodeContext.java index 73da77de274..b7461e9072d 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/nodes/helpers/platform/DefaultExecutionNodeContext.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/nodes/helpers/platform/DefaultExecutionNodeContext.java @@ -131,6 +131,10 @@ else if (result instanceof StreamingObjectResult) { return (T) ((StreamingObjectResult) result).getObjectStream(); } + else if (rawType.equals(List.class)) + { + return this.getResultAsParameterizedType(type, result.realizeInMemory()); + } } throw new IllegalArgumentException("Unable to convert " + result.getClass().getSimpleName() + " to " + TypeUtils.toString(type)); } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/StreamingResult.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/StreamingResult.java index 62a55912e5e..5a1bf374293 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/StreamingResult.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/StreamingResult.java @@ -60,4 +60,15 @@ public String flush(Serializer serializer) throw new RuntimeException(e); } } + + public static long getRealizeRowLimit() + { + return Long.getLong( + "org.finos.legend.engine.realizedResultRowLimit", + Long.getLong( + "org.finos.legend.engine.realizedRelationalResultRowLimit", + 1_000L + ) + ); + } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/TDSResult.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/TDSResult.java index 76723f8fcea..0bc387b7256 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/TDSResult.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/TDSResult.java @@ -100,17 +100,6 @@ public Result realizeInMemory() } } - private static long getRealizeRowLimit() - { - return Long.getLong( - "org.finos.legend.engine.realizedResultRowLimit", - Long.getLong( - "org.finos.legend.engine.realizedRelationalResultRowLimit", - 1_000L - ) - ); - } - @Override public void cancel() { diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/object/StreamingObjectResult.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/object/StreamingObjectResult.java index 4cf14bf9b2d..1a08f214980 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/object/StreamingObjectResult.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/object/StreamingObjectResult.java @@ -14,6 +14,7 @@ package org.finos.legend.engine.plan.execution.result.object; +import org.eclipse.collections.api.factory.Lists; import org.finos.legend.engine.plan.dependencies.store.shared.IResult; import org.finos.legend.engine.plan.execution.result.ConstantResult; import org.finos.legend.engine.plan.execution.result.Result; @@ -23,6 +24,7 @@ import org.finos.legend.engine.plan.execution.result.serialization.SerializationFormat; import org.finos.legend.engine.plan.execution.result.serialization.Serializer; +import java.util.List; import java.util.stream.Stream; public class StreamingObjectResult extends StreamingResult @@ -91,4 +93,22 @@ public Serializer getSerializer(SerializationFormat format) throw new RuntimeException(format.toString() + " format not currently supported with StreamingObjectResult"); } } + + @Override + public Result realizeInMemory() + { + List res = Lists.mutable.empty(); + this.getObjectStream().forEach(x -> + { + if (res.size() > StreamingResult.getRealizeRowLimit()) + { + throw new RuntimeException("Too many rows returned. Realization of relational results currently supports results with up to " + getRealizeRowLimit() + " rows."); + } + else + { + res.add(x); + } + }); + return new ConstantResult(res); + } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/pom.xml index 03ab78e82b0..b3f582a5dc4 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-base - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/legend-engine-executionPlan-generation/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/legend-engine-executionPlan-generation/pom.xml index ed34f49ba78..672f1602113 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/legend-engine-executionPlan-generation/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/legend-engine-executionPlan-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-executionPlan-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/pom.xml index da7c855f009..3f7726083da 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-generation/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-base - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler-http-api/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler-http-api/pom.xml index 85903c71ebd..337fb0d15f9 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-compiler-http-api diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/pom.xml index c8cadb53a92..4a09ccef966 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-compiler diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/MetadataWrapper.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/MetadataWrapper.java index 647ce3af3bb..c8dd9054c3d 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/MetadataWrapper.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/MetadataWrapper.java @@ -14,6 +14,7 @@ package org.finos.legend.engine.language.pure.compiler; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.map.MapIterable; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.pure.m3.coreinstance.Package; @@ -79,7 +80,7 @@ public CoreInstance getMetadata(String classifier, String id) return type; } } - throw new PureExecutionException(e); + throw new PureExecutionException(e, Stacks.mutable.empty()); } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/AssociationCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/AssociationCompilerExtension.java new file mode 100644 index 00000000000..6dfd98921fd --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/AssociationCompilerExtension.java @@ -0,0 +1,147 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.ListIterable; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Association_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification; + +public class AssociationCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "Association"); + } + + @Override + public CompilerExtension build() + { + return new AssociationCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + Association.class, + Lists.fixedSize.with(Class.class), + this::associationFirstPass, + this::associationSecondPass, + this::associationThirdPass + ) + ); + } + + private PackageableElement associationFirstPass(Association srcAssociation, CompileContext context) + { + String packageString = context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association association = new Root_meta_pure_metamodel_relationship_Association_Impl(srcAssociation.name, null, context.pureModel.getClass("meta::pure::metamodel::relationship::Association")); + + if (srcAssociation.properties.size() != 2) + { + throw new EngineException("Expected 2 properties for an association '" + packageString + "'", srcAssociation.sourceInformation, EngineErrorType.COMPILATION); + } + return association._stereotypes(ListIterate.collect(srcAssociation.stereotypes, context::resolveStereotype)) + ._taggedValues(ListIterate.collect(srcAssociation.taggedValues, context::newTaggedValue)); + } + + private void associationSecondPass(Association srcAssociation, CompileContext context) + { + String packageString = context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association association = context.pureModel.getAssociation(packageString, srcAssociation.sourceInformation); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class source = context.resolveClass(srcAssociation.properties.get(0).type, srcAssociation.properties.get(0).sourceInformation); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class target = context.resolveClass(srcAssociation.properties.get(1).type, srcAssociation.properties.get(1).sourceInformation); + + String property0Ref = context.pureModel.addPrefixToTypeReference(HelperModelBuilder.getElementFullPath(source, context.pureModel.getExecutionSupport())); + String property1Ref = context.pureModel.addPrefixToTypeReference(HelperModelBuilder.getElementFullPath(target, context.pureModel.getExecutionSupport())); + + // TODO generalize this validation to all platform/core types + if ("meta::pure::metamodel::type::Any".equals(org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement.getUserPathForPackageableElement(source)) || + "meta::pure::metamodel::type::Any".equals(org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement.getUserPathForPackageableElement(target))) + { + throw new EngineException("Associations to Any are not allowed. Found in '" + packageString + "'", srcAssociation.sourceInformation, EngineErrorType.COMPILATION); + } + + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property property1 = HelperModelBuilder.processProperty(context, context.pureModel.getGenericTypeFromIndex(property1Ref), association).valueOf(srcAssociation.properties.get(0)); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property property2 = HelperModelBuilder.processProperty(context, context.pureModel.getGenericTypeFromIndex(property0Ref), association).valueOf(srcAssociation.properties.get(1)); + + synchronized (source) + { + source._propertiesFromAssociationsAdd(property2); + } + synchronized (target) + { + target._propertiesFromAssociationsAdd(property1); + } + + ProcessingContext ctx = new ProcessingContext("Association " + packageString + " (second pass)"); + + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(context, property1Ref); + ctx.addInferredVariables("this", thisVariable); + + ListIterable> qualifiedProperties = ListIterate.collect(srcAssociation.qualifiedProperties, p -> + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class cl = context.resolveGenericType(p.returnType, p.sourceInformation)._rawType() == source ? target : source; + return HelperModelBuilder.processQualifiedPropertyFirstPass(context, association, org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement.getUserPathForPackageableElement(cl), ctx).valueOf(p); + }); + qualifiedProperties.forEach(q -> + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class _class = q._genericType()._rawType() == source ? target : source; + synchronized (_class) + { + _class._qualifiedPropertiesFromAssociationsAdd(q); + } + }); + ctx.flushVariable("this"); + association._originalMilestonedProperties(ListIterate.collect(srcAssociation.originalMilestonedProperties, HelperModelBuilder.processProperty(context, context.pureModel.getGenericTypeFromIndex(srcAssociation.properties.get(0).type), association))) + ._properties(Lists.mutable.with(property1, property2)) + ._qualifiedProperties(qualifiedProperties); + } + + private void associationThirdPass(Association srcAssociation, CompileContext context) + { + String property0Ref = context.pureModel.addPrefixToTypeReference(srcAssociation.properties.get(0).type); + String property1Ref = context.pureModel.addPrefixToTypeReference(srcAssociation.properties.get(1).type); + + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association association = context.pureModel.getAssociation(context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name), srcAssociation.sourceInformation); + ProcessingContext ctx = new ProcessingContext("Association " + context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name) + " (third pass)"); + + ListIterate.collect(srcAssociation.qualifiedProperties, property -> + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(context, srcAssociation.properties.get(0).type.equals(property.returnType) ? property1Ref : property0Ref); + ctx.addInferredVariables("this", thisVariable); + ctx.push("Qualified Property " + property.name); + ListIterate.collect(property.parameters, expression -> expression.accept(new ValueSpecificationBuilder(context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); + MutableList body = ListIterate.collect(property.body, expression -> expression.accept(new ValueSpecificationBuilder(context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty prop = association._qualifiedProperties().detect(o -> o._name().equals(property.name)); + ctx.pop(); + ctx.flushVariable("this"); + return prop._expressionSequence(body); + }); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/ClassCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/ClassCompilerExtension.java new file mode 100644 index 00000000000..3acd87d53eb --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/ClassCompilerExtension.java @@ -0,0 +1,180 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure; +import org.finos.legend.engine.shared.core.identity.Identity; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; +import org.finos.legend.engine.shared.core.operational.logs.LogInfo; +import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Class_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification; +import org.slf4j.Logger; + +import java.util.Set; + +public class ClassCompilerExtension implements CompilerExtension +{ + private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(ClassCompilerExtension.class); + + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "Class"); + } + + @Override + public CompilerExtension build() + { + return new ClassCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + Class.class, + Lists.fixedSize.with(Measure.class), + this::classFirstPass, + this::classSecondPass, + this::classThirdPass + ) + ); + } + + private PackageableElement classFirstPass(Class srcClass, CompileContext context) + { + String fullPath = context.pureModel.buildPackageString(srcClass._package, srcClass.name); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class targetClass = new Root_meta_pure_metamodel_type_Class_Impl<>(srcClass.name, SourceInformationHelper.toM3SourceInformation(srcClass.sourceInformation), context.pureModel.getClass("meta::pure::metamodel::type::Class")); + context.pureModel.typesIndex.put(fullPath, targetClass); + GenericType genericType = context.newGenericType(targetClass);; + context.pureModel.typesGenericTypeIndex.put(fullPath, genericType); + return targetClass._classifierGenericType(context.newGenericType(context.pureModel.getType("meta::pure::metamodel::type::Class"), genericType)) + ._stereotypes(ListIterate.collect(srcClass.stereotypes, context::resolveStereotype)) + ._taggedValues(ListIterate.collect(srcClass.taggedValues, context::newTaggedValue)); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + private void classSecondPass(Class srcClass, CompileContext context) + { + String fullPath = context.pureModel.buildPackageString(srcClass._package, srcClass.name); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class _class = context.pureModel.getClass(fullPath, srcClass.sourceInformation); + GenericType _classGenericType = context.resolveGenericType(fullPath, srcClass.sourceInformation); + Set uniqueSuperTypes = Sets.mutable.empty(); + MutableList generalization = ListIterate.collect(srcClass.superTypes, superTypePtr -> + { + String superType = superTypePtr.path; + // validate no duplicated class supertype + if (!uniqueSuperTypes.add(superType)) + { + throw new EngineException("Duplicated super type '" + superType + "' in class '" + context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "'", srcClass.sourceInformation, EngineErrorType.COMPILATION); + } + Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("", SourceInformationHelper.toM3SourceInformation(superTypePtr.sourceInformation), context.pureModel.getClass("meta::pure::metamodel::relationship::Generalization"))._general(context.resolveGenericType(superType, superTypePtr.sourceInformation))._specific(_class); + if (!context.pureModel.isImmutable(superType)) + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class superTypeClass; + Type type = context.resolveType(superType, superTypePtr.sourceInformation); + try + { + superTypeClass = (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) type; + } + catch (ClassCastException e) + { + throw new EngineException("Invalid supertype: '" + srcClass.name + "' cannot extend '" + superType + "' as it is not a class.", srcClass.sourceInformation, EngineErrorType.COMPILATION); + } + synchronized (superTypeClass) + { + superTypeClass._specializationsAdd(g); + } + } + return g; + }); + + MutableList> properties = ListIterate.collect(srcClass.properties, HelperModelBuilder.processProperty(context, _classGenericType, _class)); + MutableList> restrictedMilestoningProperties = Milestoning.restrictedMilestoningProperties(_class, srcClass, properties, context.pureModel); + MutableList> withMilestoningProperties = properties.select(p -> !restrictedMilestoningProperties.contains(p)).withAll(Milestoning.generateMilestoningProperties(_class, context)); + + ProcessingContext ctx = new ProcessingContext("Class '" + context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' Second Pass"); + ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(context, context.pureModel.buildPackageString(srcClass._package, srcClass.name)); + ctx.addInferredVariables("this", thisVariable); + + RichIterable> qualifiedProperties = ListIterate.collect(srcClass.qualifiedProperties, HelperModelBuilder.processQualifiedPropertyFirstPass(context, _class, context.pureModel.buildPackageString(srcClass._package, srcClass.name), ctx)); + _class._originalMilestonedProperties(ListIterate.collect(srcClass.originalMilestonedProperties, HelperModelBuilder.processProperty(context, _classGenericType, _class))) + ._generalizations(generalization) + ._qualifiedProperties(qualifiedProperties) + ._properties(withMilestoningProperties); + if (_class._generalizations().isEmpty()) + { + Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("", null, context.pureModel.getClass("meta::pure::metamodel::relationship::Generalization")) + ._general(context.pureModel.getGenericType("meta::pure::metamodel::type::Any")) + ._specific(_class); + _class._generalizationsAdd(g); + } + ctx.flushVariable("this"); + } + + private void classThirdPass(Class srcClass, CompileContext context) + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class targetClass = context.pureModel.getClass(context.pureModel.buildPackageString(srcClass._package, srcClass.name), srcClass.sourceInformation); + + ProcessingContext ctx = new ProcessingContext("Class '" + context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' Third Pass"); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(context, context.pureModel.buildPackageString(srcClass._package, srcClass.name)); + + ListIterate.collect(srcClass.qualifiedProperties, property -> + { + ctx.push("Qualified Property " + property.name); + ctx.addInferredVariables("this", thisVariable); + MutableList body; + try + { + property.parameters.forEach(p -> p.accept(new ValueSpecificationBuilder(context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); + body = ListIterate.collect(property.body, expression -> expression.accept(new ValueSpecificationBuilder(context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); + } + catch (Exception e) + { + LOGGER.warn(new LogInfo(Identity.getAnonymousIdentity().getName(), LoggingEventType.GRAPH_EXPRESSION_ERROR, "Can't build derived property '" + property.name + " of class '" + context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' - stack: " + ctx.getStack()).toString()); + if (e instanceof EngineException) + { + throw e; + } + e.printStackTrace(); + throw new EngineException(e.getMessage(), property.sourceInformation, EngineErrorType.COMPILATION); + } + ctx.flushVariable("this"); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty prop = targetClass._qualifiedProperties().detect(o -> HelperModelBuilder.isCompatibleDerivedProperty(o, property)); + HelperModelBuilder.checkCompatibility(context, body.getLast()._genericType()._rawType(), body.getLast()._multiplicity(), prop._genericType()._rawType(), prop._multiplicity(), "Error in derived property '" + srcClass.name + "." + property.name + "'", property.body.get(property.body.size() - 1).sourceInformation); + ctx.pop(); + return prop._expressionSequence(body); + }); + + HelperModelBuilder.processClassConstraints(srcClass, context, targetClass, ctx, thisVariable); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/CompileContext.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/CompileContext.java index 3b4bfa7f02f..b42e890b265 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/CompileContext.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/CompileContext.java @@ -14,6 +14,8 @@ package org.finos.legend.engine.language.pure.compiler.toPureGraph; +import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.factory.Sets; import org.eclipse.collections.api.list.MutableList; @@ -27,22 +29,28 @@ import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.StereotypePtr; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TagPtr; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.ImportAwareCodeSection; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.Section; import org.finos.legend.engine.shared.core.deployment.DeploymentMode; import org.finos.legend.engine.shared.core.identity.Identity; -import org.finos.legend.engine.shared.core.identity.factory.*; import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; import org.finos.legend.engine.shared.core.operational.logs.LogInfo; import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType; import org.finos.legend.pure.generated.Root_meta_core_runtime_Connection; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_TaggedValue_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl; import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableConnection; import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableRuntime; import org.finos.legend.pure.generated.Root_meta_core_runtime_Runtime; import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.TaggedValue; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Measure; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Unit; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.SimpleFunctionExpression; @@ -166,6 +174,31 @@ public Processor getExtraProcessorOrThrow(PackageableElement element) return getCompilerExtensions().getExtraProcessorOrThrow(element); } + public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement processFirstPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement pureElement = getExtraProcessorOrThrow(element).processFirstPass(element, this); + if (pureElement instanceof ConcreteFunctionDefinition) + { + return pureElement; + } + return this.pureModel.setNameAndPackage(pureElement, element.name, element._package, element.sourceInformation); + } + + public void processSecondPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + { + getExtraProcessorOrThrow(element).processSecondPass(element, this); + } + + protected RichIterable processPrerequisiteElementsPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + { + return getExtraProcessorOrThrow(element).getPrerequisiteElements(element, this); + } + + public void processThirdPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + { + getExtraProcessorOrThrow(element).processThirdPass(element, this); + } + public T resolve(String path, SourceInformation sourceInformation, Function resolver) { if (path == null) @@ -377,6 +410,11 @@ public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum resol return this.pureModel.getEnumValue(this.resolveEnumeration(fullPath, enumerationSourceInformation), fullPath, value, sourceInformation); } + public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Stereotype resolveStereotype(StereotypePtr stereotypePointer) + { + return this.resolveStereotype(stereotypePointer.profile, stereotypePointer.value, stereotypePointer.profileSourceInformation, stereotypePointer.sourceInformation); + } + public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Stereotype resolveStereotype(String fullPath, String value) { return this.resolveStereotype(fullPath, value, SourceInformation.getUnknownSourceInformation(), SourceInformation.getUnknownSourceInformation()); @@ -387,6 +425,11 @@ public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Stere return this.pureModel.getStereotype(this.resolveProfile(fullPath, profileSourceInformation), fullPath, value, sourceInformation); } + public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Tag resolveTag(TagPtr tagPointer) + { + return this.resolveTag(tagPointer.profile, tagPointer.value, tagPointer.profileSourceInformation, tagPointer.sourceInformation); + } + public org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Tag resolveTag(String fullPath, String value, SourceInformation profileSourceInformation, SourceInformation sourceInformation) { return this.pureModel.getTag(this.resolveProfile(fullPath, profileSourceInformation), fullPath, value, sourceInformation); @@ -491,4 +534,30 @@ private MutableMap searchImports(String name, Function }); return results; } + + + // ------------------------------------------ SUB-ELEMENT UTILITY ----------------------------------------- + + public GenericType newGenericType(Type rawType) + { + return new Root_meta_pure_metamodel_type_generics_GenericType_Impl("", null, this.pureModel.getClass("meta::pure::metamodel::type::generics::GenericType")) + ._rawType(rawType); + } + + public GenericType newGenericType(Type rawType, GenericType typeArgument) + { + return newGenericType(rawType, Lists.fixedSize.with(typeArgument)); + } + + public GenericType newGenericType(Type rawType, RichIterable typeArguments) + { + return newGenericType(rawType)._typeArguments(typeArguments); + } + + public TaggedValue newTaggedValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TaggedValue taggedValue) + { + return new Root_meta_pure_metamodel_extension_TaggedValue_Impl("", null, this.pureModel.getClass("meta::pure::metamodel::extension::TaggedValue")) + ._tag(resolveTag(taggedValue.tag)) + ._value(taggedValue.value); + } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataElementCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataElementCompilerExtension.java new file mode 100644 index 00000000000..7f3161235eb --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataElementCompilerExtension.java @@ -0,0 +1,81 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.data.EmbeddedDataFirstPassBuilder; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; +import org.finos.legend.pure.generated.Root_meta_pure_data_DataElement; +import org.finos.legend.pure.generated.Root_meta_pure_data_DataElementReference; +import org.finos.legend.pure.generated.Root_meta_pure_data_DataElement_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_data_EmbeddedData; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; + +public class DataElementCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "DataElement"); + } + + @Override + public CompilerExtension build() + { + return new DataElementCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + DataElement.class, + this::dataElementFirstPass, + this::dataElementSecondPass + ) + ); + } + + private PackageableElement dataElementFirstPass(DataElement dataElement, CompileContext context) + { + Root_meta_pure_data_DataElement compiled = new Root_meta_pure_data_DataElement_Impl(dataElement.name, SourceInformationHelper.toM3SourceInformation(dataElement.sourceInformation), null); + GenericType mappingGenericType = context.newGenericType(context.pureModel.getType("meta::pure::data::DataElement")); + return compiled._classifierGenericType(mappingGenericType) + ._stereotypes(ListIterate.collect(dataElement.stereotypes, context::resolveStereotype)) + ._taggedValues(ListIterate.collect(dataElement.taggedValues, context::newTaggedValue)); + } + + private void dataElementSecondPass(DataElement dataElement, CompileContext context) + { + String fullPath = context.pureModel.buildPackageString(dataElement._package, dataElement.name); + Root_meta_pure_data_DataElement compiled = (Root_meta_pure_data_DataElement) context.pureModel.getPackageableElement(fullPath); + + ProcessingContext processingContext = new ProcessingContext("Data '" + fullPath + "' Second Pass"); + Root_meta_pure_data_EmbeddedData compiledData = dataElement.data.accept(new EmbeddedDataFirstPassBuilder(context, processingContext)); + if (compiledData instanceof Root_meta_pure_data_DataElementReference) + { + throw new EngineException("Cannot use Data element reference in a Data element", dataElement.data.sourceInformation, EngineErrorType.COMPILATION); + } + compiled._data(compiledData); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DependencyManagement.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DependencyManagement.java index b256a11bb3d..d286160dd12 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DependencyManagement.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DependencyManagement.java @@ -17,9 +17,13 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.list.FixedSizeList; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; import org.eclipse.collections.api.set.MutableSet; +import org.eclipse.collections.api.tuple.Pair; +import org.eclipse.collections.impl.multimap.list.FastListMultimap; +import org.eclipse.collections.impl.tuple.Tuples; import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; @@ -27,6 +31,7 @@ import java.lang.reflect.Modifier; import java.util.Collection; import java.util.LinkedList; +import java.util.List; import java.util.Queue; public class DependencyManagement @@ -38,7 +43,7 @@ public class DependencyManagement private final MutableMap, Class> unionFind = Maps.mutable.empty(); private final MutableSet>> disjointDependencyGraphs = Sets.mutable.empty(); - public DependencyManagement(MutableMap, Collection>> dependencyGraph) + public void processDependencyGraph(MutableMap, Collection>> dependencyGraph) { MutableSet> abstractClasses = Sets.mutable.empty(); dependencyGraph.forEach((dependent, dependencies) -> @@ -129,6 +134,140 @@ public void detectCircularDependency() } } + public FastListMultimap, PackageableElementsByDependencyLevel> topologicallySortElements(FastListMultimap, PackageableElementsByDependencyLevel> classToElements, MutableMap, MutableMap>> elementPrerequisitesByClass) + { + FastListMultimap, PackageableElementsByDependencyLevel> classToElementsSortedByDependencyLevel = new FastListMultimap<>(); + classToElements.forEachKeyMultiValues((clazz, elementsByDependencyLevel) -> + { + if (elementPrerequisitesByClass.containsKey(clazz)) + { + MutableMap> elementPrerequisites = elementPrerequisitesByClass.get(clazz); + MutableMap inDegrees = Maps.mutable.empty(); + MutableMap> dependencyToDependents = Maps.mutable.empty(); + elementPrerequisites.forEachKeyValue((dependentElementFullPath, prerequisiteFullPaths) -> + { + dependencyToDependents.putIfAbsent(dependentElementFullPath, Lists.mutable.empty()); + inDegrees.put(dependentElementFullPath, inDegrees.getOrDefault(dependentElementFullPath, 0) + prerequisiteFullPaths.size()); + prerequisiteFullPaths.forEach(prerequisiteFullPath -> + { + dependencyToDependents.putIfAbsent(prerequisiteFullPath, Lists.mutable.empty()); + dependencyToDependents.get(prerequisiteFullPath).add(dependentElementFullPath); + }); + }); + MutableMap packageableElementsIndex = Maps.mutable.empty(); + elementsByDependencyLevel.forEach(elementsInCurrentDependencyLevel -> + { + elementsInCurrentDependencyLevel.getIndependentElementAndPathPairs().forEach(elementAndPathPair -> + { + PackageableElement element = elementAndPathPair.getOne(); + String elementFullPath = elementAndPathPair.getTwo(); + packageableElementsIndex.put(elementFullPath, element); + inDegrees.putIfAbsent(elementFullPath, 0); + }); + }); + + Queue queue = new LinkedList<>(); + inDegrees.forEach((elementFullPath, inDegree) -> + { + if (inDegree == 0) + { + queue.offer(elementFullPath); + } + }); + + int sortedElementCount = 0; + MutableList elementsSortedByDependencyLevel = Lists.mutable.empty(); + while (!queue.isEmpty()) + { + int size = queue.size(); + MutableList> currentDependencyLevelElements = Lists.mutable.empty(); + for (int i = 0; i < size; i++) + { + String elementFullPath = queue.poll(); + currentDependencyLevelElements.add(Tuples.pair(packageableElementsIndex.get(elementFullPath), elementFullPath)); + sortedElementCount++; + dependencyToDependents.getOrDefault(elementFullPath, Lists.fixedSize.empty()).forEach(dependent -> + { + inDegrees.put(dependent, inDegrees.getOrDefault(dependent, 0) - 1); + if (inDegrees.get(dependent) == 0) + { + queue.offer(dependent); + } + }); + } + elementsSortedByDependencyLevel.add(new PackageableElementsByDependencyLevel(currentDependencyLevelElements)); + } + + if (sortedElementCount != packageableElementsIndex.size()) + { + throw new EngineException("Detected a circular dependency in element prerequisites graph in the following metamodel: " + clazz + ".\nCycle: " + getElementsInCircularDependency(elementPrerequisites), EngineErrorType.COMPILATION); + } + + classToElementsSortedByDependencyLevel.putAll(clazz, elementsSortedByDependencyLevel); + } + + else + { + classToElementsSortedByDependencyLevel.putAll(clazz, elementsByDependencyLevel); + } + }); + + return classToElementsSortedByDependencyLevel; + } + + private String getElementsInCircularDependency(MutableMap> elementPrerequisites) + { + StringBuilder cycleBuilder = new StringBuilder(); + MutableSet visitedElements = Sets.mutable.empty(); + MutableSet stack = Sets.mutable.empty(); + MutableList cycle = Lists.mutable.empty(); + + for (String dependentElementFullPath : elementPrerequisites.keySet()) + { + if (!visitedElements.contains(dependentElementFullPath)) + { + if (dfs(cycleBuilder, elementPrerequisites, dependentElementFullPath, visitedElements, stack, cycle)) + { + break; + } + } + } + + return cycleBuilder.toString(); + } + + private boolean dfs(StringBuilder cycleBuilder, MutableMap> elementPrerequisites, String currentElementPath, MutableSet visitedElements, MutableSet stack, MutableList cycle) + { + visitedElements.add(currentElementPath); + stack.add(currentElementPath); + cycle.add(currentElementPath); + + for (String prerequisiteFullPath : elementPrerequisites.getOrDefault(currentElementPath, Sets.mutable.empty())) + { + if (!visitedElements.contains(prerequisiteFullPath)) + { + if (dfs(cycleBuilder, elementPrerequisites, prerequisiteFullPath, visitedElements, stack, cycle)) + { + return true; + } + } + else if (stack.contains(prerequisiteFullPath)) + { + int cycleStart = cycle.indexOf(prerequisiteFullPath); + for (int i = cycleStart; i < cycle.size(); i++) + { + cycleBuilder.append(cycle.get(i)).append(" -> "); + } + cycleBuilder.append(cycle.get(cycleStart)); + return true; + } + } + + stack.remove(currentElementPath); + cycle.remove(cycle.size() - 1); + return false; + } + public MutableMap, Collection>> getDependentToDependencies() { return dependentToDependencies == null ? Maps.fixedSize.empty() : dependentToDependencies; @@ -210,4 +349,19 @@ private void union(Class p, Class> independentElementAndPathPairs; + + protected PackageableElementsByDependencyLevel(Collection> packageableElementAndPathPairs) + { + this.independentElementAndPathPairs = Lists.fixedSize.withAll(packageableElementAndPathPairs); + } + + protected FixedSizeList> getIndependentElementAndPathPairs() + { + return this.independentElementAndPathPairs; + } + } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/EnumerationCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/EnumerationCompilerExtension.java new file mode 100644 index 00000000000..6a2bcda0551 --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/EnumerationCompilerExtension.java @@ -0,0 +1,84 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Enum_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Enumeration_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; + +public class EnumerationCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "Enumeration"); + } + + @Override + public CompilerExtension build() + { + return new EnumerationCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + Enumeration.class, + this::enumerationFirstPass, + this::enumerationSecondPass + ) + ); + } + + private PackageableElement enumerationFirstPass(Enumeration enumeration, CompileContext context) + { + String fullPath = context.pureModel.buildPackageString(enumeration._package, enumeration.name); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration en = new Root_meta_pure_metamodel_type_Enumeration_Impl<>(enumeration.name, SourceInformationHelper.toM3SourceInformation(enumeration.sourceInformation), context.pureModel.getClass("meta::pure::metamodel::type::Enumeration")); + context.pureModel.typesIndex.put(fullPath, en); + GenericType genericType = context.newGenericType(en); + context.pureModel.typesGenericTypeIndex.put(fullPath, genericType); + return en._classifierGenericType(context.newGenericType(context.pureModel.getClass("meta::pure::metamodel::type::Enumeration"), genericType)) + ._stereotypes(ListIterate.collect(enumeration.stereotypes, context::resolveStereotype)) + ._taggedValues(ListIterate.collect(enumeration.taggedValues, context::newTaggedValue)) + ._values(ListIterate.collect(enumeration.values, v -> new Root_meta_pure_metamodel_type_Enum_Impl(v.value, SourceInformationHelper.toM3SourceInformation(v.sourceInformation), null) + ._classifierGenericType(genericType) + ._stereotypes(ListIterate.collect(v.stereotypes, context::resolveStereotype)) + ._taggedValues(ListIterate.collect(v.taggedValues, context::newTaggedValue)) + ._name(v.value))); + } + + private void enumerationSecondPass(Enumeration enumeration, CompileContext context) + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration targetEnum = (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration) context.pureModel.getType(context.pureModel.buildPackageString(enumeration._package, enumeration.name), enumeration.sourceInformation); + if (targetEnum._generalizations().isEmpty()) + { + Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("", null, context.pureModel.getClass("meta::pure::metamodel::relationship::Generalization")) + ._general(context.pureModel.getGenericType("meta::pure::metamodel::type::Any")) + ._specific(targetEnum); + targetEnum._generalizationsAdd(g); + } + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/FunctionCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/FunctionCompilerExtension.java new file mode 100644 index 00000000000..6fa8c1dad6b --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/FunctionCompilerExtension.java @@ -0,0 +1,140 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.UserDefinedFunctionHandler; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.inference.TypeAndMultiplicity; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.externalFormat.Binding; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; +import org.finos.legend.engine.shared.core.identity.Identity; +import org.finos.legend.engine.shared.core.operational.logs.LogInfo; +import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_ConcreteFunctionDefinition_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression; +import org.slf4j.Logger; + +import java.util.List; + +public class FunctionCompilerExtension implements CompilerExtension +{ + private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(FunctionCompilerExtension.class); + + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "Function"); + } + + @Override + public CompilerExtension build() + { + return new FunctionCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + Function.class, + Lists.fixedSize.with(DataElement.class, Class.class, Association.class, Mapping.class, Binding.class), + this::functionFirstPass, + (Function function, CompileContext context) -> + { + }, + this::functionThirdPass + ) + ); + } + + private PackageableElement functionFirstPass(Function function, CompileContext context) + { + // NOTE: in the protocol, we still store the function name as is, but in the function index, we will store the function based on its function signature + String functionSignature = HelperModelBuilder.getSignature(function); + String functionFullName = context.pureModel.buildPackageString(function._package, functionSignature); + String functionName = context.pureModel.buildPackageString(function._package, HelperModelBuilder.getFunctionNameWithoutSignature(function)); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition targetFunc = new Root_meta_pure_metamodel_function_ConcreteFunctionDefinition_Impl<>(functionSignature, SourceInformationHelper.toM3SourceInformation(function.sourceInformation), null); + + ProcessingContext ctx = new ProcessingContext("Function '" + functionFullName + "' First Pass"); + + context.pureModel.setNameAndPackage(targetFunc, functionSignature, function._package, function.sourceInformation) + ._functionName(functionName) // function name to be used in the handler map -> meta::pure::functions::date::isAfterDay + ._classifierGenericType(context.newGenericType(context.pureModel.getType("meta::pure::metamodel::function::ConcreteFunctionDefinition"), PureModel.buildFunctionType(ListIterate.collect(function.parameters, p -> (VariableExpression) p.accept(new ValueSpecificationBuilder(context, Lists.mutable.empty(), ctx))), context.resolveGenericType(function.returnType, function.sourceInformation), context.pureModel.getMultiplicity(function.returnMultiplicity), context.pureModel))) + ._stereotypes(ListIterate.collect(function.stereotypes, context::resolveStereotype)) + ._taggedValues(ListIterate.collect(function.taggedValues, context::newTaggedValue)); + HelperModelBuilder.processFunctionConstraints(function, context, targetFunc, ctx); + + context.pureModel.handlers.register(new UserDefinedFunctionHandler(context.pureModel, functionFullName, targetFunc, + ps -> new TypeAndMultiplicity(context.resolveGenericType(function.returnType, function.sourceInformation), context.pureModel.getMultiplicity(function.returnMultiplicity)), + ps -> + { + List vs = ListIterate.collect(function.parameters, p -> p.accept(new ValueSpecificationBuilder(context, Lists.mutable.empty(), ctx))); + if (ps.size() == function.parameters.size()) + { + int size = ps.size(); + // TODO clean up the check.... + try + { + for (int i = 0; i < size; i++) + { + HelperModelBuilder.checkCompatibility(context, ps.get(i)._genericType()._rawType(), ps.get(i)._multiplicity(), vs.get(i)._genericType()._rawType(), vs.get(i)._multiplicity(), "Error in function '" + functionFullName + "'", function.body.get(function.body.size() - 1).sourceInformation); + } + } + catch (Exception e) + { + return false; + } + return true; + } + return false; + })); + return targetFunc; + } + + private void functionThirdPass(Function function, CompileContext context) + { + String packageString = context.pureModel.buildPackageString(function._package, HelperModelBuilder.getSignature(function)); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition targetFunc = context.pureModel.getConcreteFunctionDefinition(packageString, function.sourceInformation); + ProcessingContext ctx = new ProcessingContext("Function '" + packageString + "' Third Pass"); + MutableList body; + try + { + function.parameters.forEach(p -> p.accept(new ValueSpecificationBuilder(context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); + body = ListIterate.collect(function.body, expression -> expression.accept(new ValueSpecificationBuilder(context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); + } + catch (Exception e) + { + LOGGER.warn(new LogInfo(Identity.getAnonymousIdentity().getName(), LoggingEventType.GRAPH_EXPRESSION_ERROR, "Can't build function '" + packageString + "' - stack: " + ctx.getStack()).toString()); + throw e; + } + FunctionType fType = ((FunctionType) targetFunc._classifierGenericType()._typeArguments().getFirst()._rawType()); + HelperModelBuilder.checkCompatibility(context, body.getLast()._genericType()._rawType(), body.getLast()._multiplicity(), fType._returnType()._rawType(), fType._returnMultiplicity(), "Error in function '" + packageString + "'", function.body.get(function.body.size() - 1).sourceInformation); + ctx.pop(); + targetFunc._expressionSequence(body); + HelperFunctionBuilder.processFunctionSuites(function, targetFunc, context, ctx); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperMappingBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperMappingBuilder.java index 2efe317da26..fd7c68ef5b9 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperMappingBuilder.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperMappingBuilder.java @@ -375,9 +375,11 @@ public static Root_meta_pure_mapping_MappingClass_Impl processMappingClass(org.f { mappingClass._setImplementation(mappingclass.setImplementation.accept(new ClassMappingFirstPassBuilder(context, parent)).getOne()); } - if (mappingclass.rootClass != null) + org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class rootClass = mappingclass.rootClass; + if (rootClass != null) { - mappingClass._class((org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) mappingclass.rootClass.accept(new PackageableElementThirdPassBuilder(context))); + context.processThirdPass(rootClass); + mappingClass._class(context.pureModel.getClass(context.pureModel.buildPackageString(rootClass._package, rootClass.name), rootClass.sourceInformation)); } return mappingClass; } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java index 07412f27e4d..42b0e1a9e7b 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java @@ -80,7 +80,7 @@ public static org.eclipse.collections.api.block.function.Function lambdaFunction = HelperValueSpecificationBuilder.buildLambda(Collections.singletonList(property.defaultValue.value), Collections.emptyList(), context); - defaultValue = new Root_meta_pure_metamodel_function_property_DefaultValue_Impl(null, SourceInformationHelper.toM3SourceInformation(property.defaultValue.sourceInformation), null); + defaultValue = new Root_meta_pure_metamodel_function_property_DefaultValue_Impl(null, SourceInformationHelper.toM3SourceInformation(property.defaultValue.sourceInformation), context.pureModel.getClass("meta::pure::metamodel::function::property::DefaultValue")); defaultValue._functionDefinition(lambdaFunction); } GenericType returnGenericType = context.resolveGenericType(property.type, property.propertyTypeSourceInformation); @@ -203,7 +203,7 @@ public static void checkMultiplicityCompatibility(org.finos.legend.pure.m3.corei public static void processClassConstraints(Class srcClass, CompileContext context, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class targetClass, ProcessingContext ctx, ValueSpecification thisVariable) { ctx.addInferredVariables("this", thisVariable); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ClassConstraintValueSpecificationContext classConstraintValueSpecificationContext = new Root_meta_pure_metamodel_valuespecification_ClassConstraintValueSpecificationContext_Impl("", null, context.pureModel.getClass("meta::pure::metamodel::valuespecification::ClassConstraintValueSpecificationContext"))._class(targetClass); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ClassConstraintValueSpecificationContext classConstraintValueSpecificationContext = new Root_meta_pure_metamodel_valuespecification_ClassConstraintValueSpecificationContext_Impl("", null, context.pureModel.getClass("meta::pure::metamodel::valuespecification::ClassConstraintValueSpecificationContext"))._type(targetClass); RichIterable pureConstraints = processConstraints(srcClass.constraints, context, srcClass._package, srcClass.name, classConstraintValueSpecificationContext, ctx); ctx.flushVariable("this"); targetClass._constraints(pureConstraints); @@ -265,7 +265,7 @@ public static RichIterable group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "Mapping"); + } + + @Override + public CompilerExtension build() + { + return new MappingCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + Mapping.class, + Lists.fixedSize.with(Enumeration.class, Class.class, Association.class, Binding.class, Store.class), + this::mappingFirstPass, + this::mappingSecondPass, + this::mappingThirdPass, + this::mappingPrerequisiteElementsPass + ) + ); + } + + private PackageableElement mappingFirstPass(Mapping mapping, CompileContext context) + { + org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = new Root_meta_pure_mapping_Mapping_Impl(mapping.name, SourceInformationHelper.toM3SourceInformation(mapping.sourceInformation), context.pureModel.getClass("meta::pure::mapping::Mapping")); + GenericType mappingGenericType = context.newGenericType(context.pureModel.getType("meta::pure::mapping::Mapping")); + return pureMapping._classifierGenericType(mappingGenericType); + } + + private void mappingSecondPass(Mapping mapping, CompileContext context) + { + final org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = context.pureModel.getMapping(context.pureModel.buildPackageString(mapping._package, mapping.name), mapping.sourceInformation); + RichIterable> enumerationMappings = ListIterate.collect(mapping.enumerationMappings, em -> HelperMappingBuilder.processEnumMapping(em, pureMapping, context)); + if (!mapping.includedMappings.isEmpty()) + { + CompilerExtensions extensions = context.pureModel.extensions; + RichIterable mappingIncludes = + ListIterate.collect(mapping.includedMappings, i -> + { + IncludedMappingHandler handler = extensions.getExtraIncludedMappingHandlers(i.getClass().getName()); + return handler.processMappingInclude(i, context, pureMapping, + handler.resolveMapping(i, context)); + }); + pureMapping._includesAddAll(mappingIncludes); + // validate no duplicated included mappings + Set uniqueMappingIncludes = Sets.mutable.empty(); + mappingIncludes.forEach(includedMapping -> + { + String mappingName = IncludedMappingHandler.parseIncludedMappingNameRecursively(includedMapping); + if (!uniqueMappingIncludes.add(mappingName)) + { + throw new EngineException("Duplicated mapping include '" + mappingName + + "' in " + "mapping " + + "'" + context.pureModel.buildPackageString(mapping._package, mapping.name) + "'", mapping.sourceInformation, EngineErrorType.COMPILATION); + } + }); + } + if (!enumerationMappings.isEmpty()) + { + pureMapping._enumerationMappings(enumerationMappings); + } + } + + private void mappingThirdPass(Mapping mapping, CompileContext context) + { + final org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = context.pureModel.getMapping(context.pureModel.buildPackageString(mapping._package, mapping.name), mapping.sourceInformation); + if (mapping.classMappings != null && pureMapping._classMappings().isEmpty()) + { + RichIterable>> setImplementations = ListIterate.collect(mapping.classMappings, cm -> cm.accept(new ClassMappingFirstPassBuilder(context, pureMapping))); + pureMapping._classMappingsAddAll(setImplementations.flatCollect(p -> org.eclipse.collections.impl.factory.Lists.mutable.with(p.getOne()).withAll(p.getTwo()))); + } + if (!mapping.tests.isEmpty()) + { + mapping.tests.forEach(t -> HelperMappingBuilder.processMappingTest(t, context)); + } + if (mapping.testSuites != null) + { + TestBuilderHelper.validateTestSuiteIdsList(mapping.testSuites, mapping.sourceInformation); + pureMapping._tests(ListIterate.collect(mapping.testSuites, suite -> HelperMappingBuilder.processMappingTestAndTestSuite(suite, pureMapping, context))); + } + if (mapping.associationMappings != null) + { + RichIterable associationImplementations = ListIterate.collect(mapping.associationMappings, cm -> HelperMappingBuilder.processAssociationImplementation(cm, context, pureMapping)); + pureMapping._associationMappings(associationImplementations); + } + if (mapping.classMappings != null) + { + mapping.classMappings.forEach(cm -> cm.accept(new ClassMappingSecondPassBuilder(context, pureMapping))); + mapping.classMappings.forEach(cm -> cm.accept(new ClassMappingThirdPassBuilder(context, pureMapping))); + } + } + + private RichIterable mappingPrerequisiteElementsPass(Mapping mapping, CompileContext context) + { + final org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = context.pureModel.getMapping(context.pureModel.buildPackageString(mapping._package, mapping.name), mapping.sourceInformation); + return pureMapping._includes().collect(MappingIncludeAccessor::_included); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/MeasureCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/MeasureCompilerExtension.java new file mode 100644 index 00000000000..d9db9a41a77 --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/MeasureCompilerExtension.java @@ -0,0 +1,79 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Measure_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; +import org.finos.legend.pure.m3.navigation.M3Paths; + +public class MeasureCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "Measure"); + } + + @Override + public CompilerExtension build() + { + return new MeasureCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + Measure.class, + this::measureFirstPass, + this::measureSecondPass + ) + ); + } + + private PackageableElement measureFirstPass(Measure measure, CompileContext context) + { + String fullPath = context.pureModel.buildPackageString(measure._package, measure.name); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Measure targetMeasure = new Root_meta_pure_metamodel_type_Measure_Impl(measure.name, SourceInformationHelper.toM3SourceInformation(measure.sourceInformation), null); + context.pureModel.typesIndex.put(fullPath, targetMeasure); + GenericType genericType = context.newGenericType(targetMeasure); + context.pureModel.typesGenericTypeIndex.put(fullPath, genericType); + targetMeasure._classifierGenericType(context.newGenericType(context.pureModel.getType(M3Paths.Measure))); + if (measure.canonicalUnit != null) + { + HelperMeasureBuilder.processUnitPackageableElementFirstPass(measure.canonicalUnit, context); + } + measure.nonCanonicalUnits.forEach(ncu -> HelperMeasureBuilder.processUnitPackageableElementFirstPass(ncu, context)); + return targetMeasure; + } + + private void measureSecondPass(Measure measure, CompileContext context) + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Measure targetMeasure = context.pureModel.getMeasure(context.pureModel.buildPackageString(measure._package, measure.name), measure.sourceInformation); + if (measure.canonicalUnit != null) + { + targetMeasure._canonicalUnit(HelperMeasureBuilder.processUnitPackageableElementSecondPass(measure.canonicalUnit, context)); + } + targetMeasure._nonCanonicalUnits(ListIterate.collect(measure.nonCanonicalUnits, ncu -> HelperMeasureBuilder.processUnitPackageableElementSecondPass(ncu, context))); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/Milestoning.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/Milestoning.java index 9f07df47e41..b15aa2ae6b5 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/Milestoning.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/Milestoning.java @@ -182,7 +182,7 @@ private static void applyMilestoningPropertyTransformations(CompileContext conte { MutableList propertiesUpdated = Lists.mutable.withAll(properties.select(p -> !originalProperties.contains(p))).withAll((Iterable) edgePointProperties); MutableList qualifiedPropertiesUpdated = Lists.mutable.withAll(qualifiedPropertiesGetter.valueOf(clazz)).withAll((Iterable) milestoningPropertyTransformations.flatCollect(t -> t.qualfiedPropertiesToAdd)); - MutableList originalMilestonedPropertiesUpdated = Lists.mutable.withAll(originalProperties.reject(p -> originalMilestonedProperties.anySatisfy(o -> o.getName().equals(p.getName())))); + MutableList originalMilestonedPropertiesUpdated = Lists.mutable.withAll(originalProperties.reject(p -> originalMilestonedProperties.anySatisfy(o -> o.getName().equals(p.getName()) && o._owner().equals(p._owner())))); propertiesSetter.accept(clazz, propertiesUpdated); qualifiedPropertiesSetter.accept(clazz, qualifiedPropertiesUpdated); originalPropertySetter.accept(clazz, originalMilestonedPropertiesUpdated); diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableConnectionCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableConnectionCompilerExtension.java new file mode 100644 index 00000000000..67dd9366902 --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableConnectionCompilerExtension.java @@ -0,0 +1,67 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; +import org.finos.legend.pure.generated.Root_meta_core_runtime_Connection; +import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableConnection; +import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableConnection_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; + +public class PackageableConnectionCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "PackageableConnection"); + } + + @Override + public CompilerExtension build() + { + return new PackageableConnectionCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + PackageableConnection.class, + Lists.fixedSize.with(Mapping.class), + this::packageableConnectionFirstPass, + this::packageableConnectionSecondPass + ) + ); + } + + private PackageableElement packageableConnectionFirstPass(PackageableConnection packageableConnection, CompileContext context) + { + Root_meta_pure_runtime_PackageableConnection metamodel = new Root_meta_pure_runtime_PackageableConnection_Impl(packageableConnection.name, SourceInformationHelper.toM3SourceInformation(packageableConnection.sourceInformation), context.pureModel.getClass("meta::pure::runtime::PackageableConnection")); + Root_meta_core_runtime_Connection connection = packageableConnection.connectionValue.accept(new ConnectionFirstPassBuilder(context)); + return metamodel._connectionValue(connection); + } + + private void packageableConnectionSecondPass(PackageableConnection packageableConnection, CompileContext context) + { + final Root_meta_core_runtime_Connection pureConnection = context.pureModel.getConnection(context.pureModel.buildPackageString(packageableConnection._package, packageableConnection.name), packageableConnection.sourceInformation); + packageableConnection.connectionValue.accept(new ConnectionSecondPassBuilder(context, pureConnection)); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFifthPassBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFifthPassBuilder.java deleted file mode 100644 index b6cc52923ca..00000000000 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFifthPassBuilder.java +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2020 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. - -package org.finos.legend.engine.language.pure.compiler.toPureGraph; - -import org.eclipse.collections.api.RichIterable; -import org.eclipse.collections.api.list.MutableList; -import org.eclipse.collections.impl.utility.ListIterate; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; -import org.finos.legend.engine.shared.core.identity.Identity; -import org.finos.legend.engine.shared.core.identity.factory.*; -import org.finos.legend.engine.shared.core.operational.logs.LogInfo; -import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType; -import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableRuntime; -import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.AssociationImplementation; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PackageableElementFifthPassBuilder implements PackageableElementVisitor -{ - private static final Logger LOGGER = LoggerFactory.getLogger(PackageableElementFifthPassBuilder.class); - private final CompileContext context; - - public PackageableElementFifthPassBuilder(CompileContext context) - { - this.context = context; - } - - @Override - public PackageableElement visit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) - { - this.context.getExtraProcessorOrThrow(element).processFifthPass(element, this.context); - return null; - } - - @Override - public PackageableElement visit(Profile profile) - { - return null; - } - - @Override - public PackageableElement visit(Enumeration _enum) - { - return null; - } - - @Override - public PackageableElement visit(Class _class) - { - return null; - } - - @Override - public PackageableElement visit(Association association) - { - return null; - } - - @Override - public PackageableElement visit(Function function) - { - String packageString = this.context.pureModel.buildPackageString(function._package, HelperModelBuilder.getSignature(function)); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition targetFunc = this.context.pureModel.getConcreteFunctionDefinition(packageString, function.sourceInformation); - ProcessingContext ctx = new ProcessingContext("Function '" + packageString + "' Fifth Pass"); - MutableList body; - try - { - function.parameters.forEach(p -> p.accept(new ValueSpecificationBuilder(this.context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); - body = ListIterate.collect(function.body, expression -> expression.accept(new ValueSpecificationBuilder(this.context, org.eclipse.collections.api.factory.Lists.mutable.empty(), ctx))); - } - catch (Exception e) - { - LOGGER.warn(new LogInfo(Identity.getAnonymousIdentity().getName(), LoggingEventType.GRAPH_EXPRESSION_ERROR, "Can't build function '" + packageString + "' - stack: " + ctx.getStack()).toString()); - throw e; - } - FunctionType fType = ((FunctionType) targetFunc._classifierGenericType()._typeArguments().getFirst()._rawType()); - HelperModelBuilder.checkCompatibility(this.context, body.getLast()._genericType()._rawType(), body.getLast()._multiplicity(), fType._returnType()._rawType(), fType._returnMultiplicity(), "Error in function '" + packageString + "'", function.body.get(function.body.size() - 1).sourceInformation); - ctx.pop(); - targetFunc._expressionSequence(body); - HelperFunctionBuilder.processFunctionSuites(function, targetFunc, this.context, ctx); - return targetFunc; - } - - @Override - public PackageableElement visit(Measure measure) - { - return null; - } - - @Override - public PackageableElement visit(Mapping mapping) - { - final org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = this.context.pureModel.getMapping(this.context.pureModel.buildPackageString(mapping._package, mapping.name), mapping.sourceInformation); - if (mapping.associationMappings != null) - { - RichIterable associationImplementations = ListIterate.collect(mapping.associationMappings, cm -> HelperMappingBuilder.processAssociationImplementation(cm, this.context, pureMapping)); - pureMapping._associationMappings(associationImplementations); - } - if (mapping.classMappings != null) - { - mapping.classMappings.forEach(cm -> cm.accept(new ClassMappingSecondPassBuilder(this.context, pureMapping))); - } - return pureMapping; - } - - @Override - public PackageableElement visit(PackageableRuntime packageableRuntime) - { - String fullPath = this.context.pureModel.buildPackageString(packageableRuntime._package, packageableRuntime.name); - Root_meta_pure_runtime_PackageableRuntime metamodel = this.context.pureModel.getPackageableRuntime(fullPath, packageableRuntime.sourceInformation); - HelperRuntimeBuilder.buildEngineRuntime(packageableRuntime.runtimeValue, metamodel._runtimeValue(), this.context); - return metamodel; - } - - @Override - public PackageableElement visit(PackageableConnection packageableConnection) - { - return null; - } - - @Override - public PackageableElement visit(SectionIndex sectionIndex) - { - return null; - } - - @Override - public PackageableElement visit(DataElement dataElement) - { - return null; - } -} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFirstPassBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFirstPassBuilder.java deleted file mode 100644 index 8b4a3bf2480..00000000000 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFirstPassBuilder.java +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright 2020 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. - -package org.finos.legend.engine.language.pure.compiler.toPureGraph; - -import org.eclipse.collections.api.RichIterable; -import org.eclipse.collections.api.factory.Lists; -import org.eclipse.collections.impl.utility.ListIterate; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.UserDefinedFunctionHandler; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.inference.TypeAndMultiplicity; -import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; -import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.StereotypePtr; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TagPtr; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; -import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; -import org.finos.legend.pure.generated.Root_meta_core_runtime_EngineRuntime; -import org.finos.legend.pure.generated.Root_meta_core_runtime_EngineRuntime_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_data_DataElement; -import org.finos.legend.pure.generated.Root_meta_pure_data_DataElement_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_mapping_Mapping_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_Profile_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_Stereotype_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_Tag_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_TaggedValue_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_ConcreteFunctionDefinition_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Association_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_section_SectionIndex; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_section_SectionIndex_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Class_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Enum_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Enumeration_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_Measure_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl; -import org.finos.legend.pure.generated.Root_meta_core_runtime_Connection; -import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableConnection; -import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableConnection_Impl; -import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableRuntime; -import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableRuntime_Impl; -import org.finos.legend.pure.generated.Root_meta_core_runtime_Runtime; -import org.finos.legend.pure.generated.Root_meta_core_runtime_Runtime_Impl; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Stereotype; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Tag; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.TaggedValue; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression; -import org.finos.legend.pure.m3.navigation.M3Paths; - -import java.util.List; - -public class PackageableElementFirstPassBuilder implements PackageableElementVisitor -{ - private final CompileContext context; - - public PackageableElementFirstPassBuilder(CompileContext context) - { - this.context = context; - } - - @Override - public PackageableElement visit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) - { - return setNameAndPackage(this.context.getExtraProcessorOrThrow(element).processFirstPass(element, this.context), element); - } - - @Override - public PackageableElement visit(Profile profile) - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile targetProfile = new Root_meta_pure_metamodel_extension_Profile_Impl(profile.name, SourceInformationHelper.toM3SourceInformation(profile.sourceInformation), this.context.pureModel.getClass("meta::pure::metamodel::extension::Profile")); - setNameAndPackage(targetProfile, profile); - return targetProfile - ._p_stereotypes(ListIterate.collect(profile.stereotypes, st -> newStereotype(targetProfile, st.value, st.sourceInformation))) - ._p_tags(ListIterate.collect(profile.tags, t -> newTag(targetProfile, t.value, t.sourceInformation))); - } - - @Override - public PackageableElement visit(Enumeration _enum) - { - String fullPath = this.context.pureModel.buildPackageString(_enum._package, _enum.name); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration en = new Root_meta_pure_metamodel_type_Enumeration_Impl<>(_enum.name, SourceInformationHelper.toM3SourceInformation(_enum.sourceInformation), this.context.pureModel.getClass("meta::pure::metamodel::type::Enumeration")); - this.context.pureModel.typesIndex.put(fullPath, en); - GenericType genericType = newGenericType(en); - this.context.pureModel.typesGenericTypeIndex.put(fullPath, genericType); - setNameAndPackage(en, _enum); - return en._classifierGenericType(newGenericType(this.context.pureModel.getClass("meta::pure::metamodel::type::Enumeration"), genericType)) - ._stereotypes(ListIterate.collect(_enum.stereotypes, this::resolveStereotype)) - ._taggedValues(ListIterate.collect(_enum.taggedValues, this::newTaggedValue)) - ._values(ListIterate.collect(_enum.values, v -> new Root_meta_pure_metamodel_type_Enum_Impl(v.value, SourceInformationHelper.toM3SourceInformation(v.sourceInformation), null) - ._classifierGenericType(genericType) - ._stereotypes(ListIterate.collect(v.stereotypes, this::resolveStereotype)) - ._taggedValues(ListIterate.collect(v.taggedValues, this::newTaggedValue)) - ._name(v.value))); - } - - @Override - public PackageableElement visit(Class _class) - { - String fullPath = this.context.pureModel.buildPackageString(_class._package, _class.name); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class targetClass = new Root_meta_pure_metamodel_type_Class_Impl<>(_class.name, SourceInformationHelper.toM3SourceInformation(_class.sourceInformation), this.context.pureModel.getClass("meta::pure::metamodel::type::Class")); - this.context.pureModel.typesIndex.put(fullPath, targetClass); - GenericType genericType = newGenericType(targetClass); - this.context.pureModel.typesGenericTypeIndex.put(fullPath, genericType); - setNameAndPackage(targetClass, _class); - return targetClass._classifierGenericType(newGenericType(this.context.pureModel.getType("meta::pure::metamodel::type::Class"), genericType)) - ._stereotypes(ListIterate.collect(_class.stereotypes, this::resolveStereotype)) - ._taggedValues(ListIterate.collect(_class.taggedValues, this::newTaggedValue)); - } - - @Override - public PackageableElement visit(Measure measure) - { - String fullPath = this.context.pureModel.buildPackageString(measure._package, measure.name); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Measure targetMeasure = new Root_meta_pure_metamodel_type_Measure_Impl(measure.name, SourceInformationHelper.toM3SourceInformation(measure.sourceInformation), null); - this.context.pureModel.typesIndex.put(fullPath, targetMeasure); - GenericType genericType = newGenericType(targetMeasure); - this.context.pureModel.typesGenericTypeIndex.put(fullPath, genericType); - targetMeasure._classifierGenericType(newGenericType(this.context.pureModel.getType(M3Paths.Measure))); - if (measure.canonicalUnit != null) - { - HelperMeasureBuilder.processUnitPackageableElementFirstPass(measure.canonicalUnit, this.context); - } - measure.nonCanonicalUnits.forEach(ncu -> HelperMeasureBuilder.processUnitPackageableElementFirstPass(ncu, this.context)); - return setNameAndPackage(targetMeasure, measure); - } - - @Override - public PackageableElement visit(Association srcAssociation) - { - String packageString = this.context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association association = new Root_meta_pure_metamodel_relationship_Association_Impl(srcAssociation.name, null, this.context.pureModel.getClass("meta::pure::metamodel::relationship::Association")); - - if (srcAssociation.properties.size() != 2) - { - throw new EngineException("Expected 2 properties for an association '" + packageString + "'", srcAssociation.sourceInformation, EngineErrorType.COMPILATION); - } - setNameAndPackage(association, srcAssociation); - return association._stereotypes(ListIterate.collect(srcAssociation.stereotypes, this::resolveStereotype)) - ._taggedValues(ListIterate.collect(srcAssociation.taggedValues, this::newTaggedValue)); - } - - @Override - public PackageableElement visit(Function function) - { - // NOTE: in the protocol, we still store the function name as is, but in the function index, we will store the function based on its function signature - String functionSignature = HelperModelBuilder.getSignature(function); - String functionFullName = this.context.pureModel.buildPackageString(function._package, functionSignature); - String functionName = this.context.pureModel.buildPackageString(function._package, HelperModelBuilder.getFunctionNameWithoutSignature(function)); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition targetFunc = new Root_meta_pure_metamodel_function_ConcreteFunctionDefinition_Impl<>(functionSignature, SourceInformationHelper.toM3SourceInformation(function.sourceInformation), null); - - ProcessingContext ctx = new ProcessingContext("Function '" + functionFullName + "' First Pass"); - - this.context.pureModel.setNameAndPackage(targetFunc, functionSignature, function._package, function.sourceInformation) - ._functionName(functionName) // function name to be used in the handler map -> meta::pure::functions::date::isAfterDay - ._classifierGenericType(newGenericType(this.context.pureModel.getType("meta::pure::metamodel::function::ConcreteFunctionDefinition"), PureModel.buildFunctionType(ListIterate.collect(function.parameters, p -> (VariableExpression) p.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx))), this.context.resolveGenericType(function.returnType, function.sourceInformation), this.context.pureModel.getMultiplicity(function.returnMultiplicity), this.context.pureModel))) - ._stereotypes(ListIterate.collect(function.stereotypes, this::resolveStereotype)) - ._taggedValues(ListIterate.collect(function.taggedValues, this::newTaggedValue)); - HelperModelBuilder.processFunctionConstraints(function, this.context, targetFunc, ctx); - - this.context.pureModel.handlers.register(new UserDefinedFunctionHandler(this.context.pureModel, functionFullName, targetFunc, - ps -> new TypeAndMultiplicity(this.context.resolveGenericType(function.returnType, function.sourceInformation), this.context.pureModel.getMultiplicity(function.returnMultiplicity)), - ps -> - { - List vs = ListIterate.collect(function.parameters, p -> p.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx))); - if (ps.size() == function.parameters.size()) - { - int size = ps.size(); - // TODO clean up the check.... - try - { - for (int i = 0; i < size; i++) - { - HelperModelBuilder.checkCompatibility(this.context, ps.get(i)._genericType()._rawType(), ps.get(i)._multiplicity(), vs.get(i)._genericType()._rawType(), vs.get(i)._multiplicity(), "Error in function '" + functionFullName + "'", function.body.get(function.body.size() - 1).sourceInformation); - } - } - catch (Exception e) - { - return false; - } - return true; - } - return false; - })); - return targetFunc; - } - - @Override - public PackageableElement visit(Mapping mapping) - { - org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = new Root_meta_pure_mapping_Mapping_Impl(mapping.name, SourceInformationHelper.toM3SourceInformation(mapping.sourceInformation), this.context.pureModel.getClass("meta::pure::mapping::Mapping")); - GenericType mappingGenericType = newGenericType(this.context.pureModel.getType("meta::pure::mapping::Mapping")); - pureMapping._classifierGenericType(mappingGenericType); - return setNameAndPackage(pureMapping, mapping); - } - - @Override - public PackageableElement visit(PackageableRuntime packageableRuntime) - { - Root_meta_pure_runtime_PackageableRuntime metamodel = new Root_meta_pure_runtime_PackageableRuntime_Impl(packageableRuntime.name, SourceInformationHelper.toM3SourceInformation(packageableRuntime.sourceInformation), this.context.pureModel.getClass("meta::pure::runtime::PackageableRuntime")); - GenericType packageableRuntimeGenericType = newGenericType(this.context.pureModel.getType("meta::pure::runtime::PackageableRuntime")); - metamodel._classifierGenericType(packageableRuntimeGenericType); - - Root_meta_core_runtime_EngineRuntime pureRuntime = new Root_meta_core_runtime_EngineRuntime_Impl("Root::meta::core::runtime::Runtime", SourceInformationHelper.toM3SourceInformation(packageableRuntime.sourceInformation), this.context.pureModel.getClass("meta::core::runtime::Runtime")); - metamodel._runtimeValue(pureRuntime); - - return setNameAndPackage(metamodel, packageableRuntime); - } - - @Override - public PackageableElement visit(PackageableConnection packageableConnection) - { - Root_meta_pure_runtime_PackageableConnection metamodel = new Root_meta_pure_runtime_PackageableConnection_Impl(packageableConnection.name, SourceInformationHelper.toM3SourceInformation(packageableConnection.sourceInformation), this.context.pureModel.getClass("meta::pure::runtime::PackageableConnection")); - Root_meta_core_runtime_Connection connection = packageableConnection.connectionValue.accept(new ConnectionFirstPassBuilder(this.context)); - metamodel._connectionValue(connection); - return setNameAndPackage(metamodel, packageableConnection); - } - - @Override - public PackageableElement visit(SectionIndex sectionIndex) - { - Root_meta_pure_metamodel_section_SectionIndex stub = new Root_meta_pure_metamodel_section_SectionIndex_Impl(sectionIndex.name, SourceInformationHelper.toM3SourceInformation(sectionIndex.sourceInformation), this.context.pureModel.getClass("meta::pure::metamodel::section::SectionIndex")); - return setNameAndPackage(stub, sectionIndex); - } - - @Override - public PackageableElement visit(DataElement dataElement) - { - Root_meta_pure_data_DataElement compiled = new Root_meta_pure_data_DataElement_Impl(dataElement.name, SourceInformationHelper.toM3SourceInformation(dataElement.sourceInformation), null); - GenericType mappingGenericType = newGenericType(this.context.pureModel.getType("meta::pure::data::DataElement")); - setNameAndPackage(compiled, dataElement); - return compiled._classifierGenericType(mappingGenericType) - ._stereotypes(ListIterate.collect(dataElement.stereotypes, this::resolveStereotype)) - ._taggedValues(ListIterate.collect(dataElement.taggedValues, this::newTaggedValue)); - } - - private GenericType newGenericType(Type rawType) - { - return new Root_meta_pure_metamodel_type_generics_GenericType_Impl("", null, this.context.pureModel.getClass("meta::pure::metamodel::type::generics::GenericType")) - ._rawType(rawType); - } - - private GenericType newGenericType(Type rawType, GenericType typeArgument) - { - return newGenericType(rawType, Lists.fixedSize.with(typeArgument)); - } - - private GenericType newGenericType(Type rawType, RichIterable typeArguments) - { - return newGenericType(rawType)._typeArguments(typeArguments); - } - - private Stereotype newStereotype(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile profile, String name, SourceInformation sourceInformation) - { - return new Root_meta_pure_metamodel_extension_Stereotype_Impl(name, SourceInformationHelper.toM3SourceInformation(sourceInformation), this.context.pureModel.getClass("meta::pure::metamodel::extension::Stereotype")) - ._value(name) - ._profile(profile); - } - - private Tag newTag(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile profile, String name, SourceInformation sourceInformation) - { - return new Root_meta_pure_metamodel_extension_Tag_Impl(name, SourceInformationHelper.toM3SourceInformation(sourceInformation), this.context.pureModel.getClass("meta::pure::metamodel::extension::Tag")) - ._value(name) - ._profile(profile); - } - - private TaggedValue newTaggedValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.TaggedValue taggedValue) - { - return new Root_meta_pure_metamodel_extension_TaggedValue_Impl("", null, this.context.pureModel.getClass("meta::pure::metamodel::extension::TaggedValue")) - ._tag(resolveTag(taggedValue.tag)) - ._value(taggedValue.value); - } - - private Tag resolveTag(TagPtr tagPointer) - { - return this.context.resolveTag(tagPointer.profile, tagPointer.value, tagPointer.profileSourceInformation, tagPointer.sourceInformation); - } - - private Stereotype resolveStereotype(StereotypePtr stereotypePointer) - { - return this.context.resolveStereotype(stereotypePointer.profile, stereotypePointer.value, stereotypePointer.profileSourceInformation, stereotypePointer.sourceInformation); - } - - private T setNameAndPackage(T pureElement, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement sourceElement) - { - return this.context.pureModel.setNameAndPackage(pureElement, sourceElement.name, sourceElement._package, sourceElement.sourceInformation); - } -} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFourthPassBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFourthPassBuilder.java deleted file mode 100644 index bcdd9cbf5ae..00000000000 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementFourthPassBuilder.java +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright 2020 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. - -package org.finos.legend.engine.language.pure.compiler.toPureGraph; - -import org.eclipse.collections.api.RichIterable; -import org.eclipse.collections.api.list.MutableList; -import org.eclipse.collections.api.tuple.Pair; -import org.eclipse.collections.impl.factory.Lists; -import org.eclipse.collections.impl.utility.ListIterate; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.test.TestBuilderHelper; -import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; -import org.finos.legend.engine.shared.core.identity.Identity; -import org.finos.legend.engine.shared.core.identity.factory.*; -import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; -import org.finos.legend.engine.shared.core.operational.logs.LogInfo; -import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl; -import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.AssociationImplementation; -import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EmbeddedSetImplementation; -import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.SetImplementation; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification; -import org.slf4j.Logger; - -public class PackageableElementFourthPassBuilder implements PackageableElementVisitor -{ - private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(PackageableElementFourthPassBuilder.class); - - private final CompileContext context; - - public PackageableElementFourthPassBuilder(CompileContext context) - { - this.context = context; - } - - @Override - public PackageableElement visit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) - { - this.context.getExtraProcessorOrThrow(element).processFourthPass(element, this.context); - return null; - } - - @Override - public PackageableElement visit(Profile profile) - { - return null; - } - - @Override - public PackageableElement visit(Enumeration _enum) - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration targetEnum = (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration)this.context.pureModel.getType(this.context.pureModel.buildPackageString(_enum._package, _enum.name), _enum.sourceInformation); - - if (targetEnum._generalizations().isEmpty()) - { - Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("", null, this.context.pureModel.getClass("meta::pure::metamodel::relationship::Generalization")) - ._general(this.context.pureModel.getGenericType("meta::pure::metamodel::type::Any")) - ._specific(targetEnum); - targetEnum._generalizationsAdd(g); - } - - return targetEnum; - } - - @Override - public PackageableElement visit(Class srcClass) - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class targetClass = this.context.pureModel.getClass(this.context.pureModel.buildPackageString(srcClass._package, srcClass.name), srcClass.sourceInformation); - - ProcessingContext ctx = new ProcessingContext("Class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' Fourth Pass"); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(this.context, this.context.pureModel.buildPackageString(srcClass._package, srcClass.name)); - - ListIterate.collect(srcClass.qualifiedProperties, property -> - { - ctx.push("Qualified Property " + property.name); - ctx.addInferredVariables("this", thisVariable); - MutableList body; - try - { - property.parameters.forEach(p -> p.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx))); - body = ListIterate.collect(property.body, expression -> expression.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx))); - } - catch (Exception e) - { - LOGGER.warn(new LogInfo(Identity.getAnonymousIdentity().getName(), LoggingEventType.GRAPH_EXPRESSION_ERROR, "Can't build derived property '" + property.name + " of class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' - stack: " + ctx.getStack()).toString()); - if (e instanceof EngineException) - { - throw e; - } - e.printStackTrace(); - throw new EngineException(e.getMessage(), property.sourceInformation, EngineErrorType.COMPILATION); - } - ctx.flushVariable("this"); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty prop = targetClass._qualifiedProperties().detect(o -> HelperModelBuilder.isCompatibleDerivedProperty(o, property)); - HelperModelBuilder.checkCompatibility(this.context, body.getLast()._genericType()._rawType(), body.getLast()._multiplicity(), prop._genericType()._rawType(), prop._multiplicity(), "Error in derived property '" + srcClass.name + "." + property.name + "'", property.body.get(property.body.size() - 1).sourceInformation); - ctx.pop(); - return prop._expressionSequence(body); - }); - - HelperModelBuilder.processClassConstraints(srcClass, this.context, targetClass, ctx, thisVariable); - - return targetClass; - } - - @Override - public PackageableElement visit(Association srcAssociation) - { - String property0Ref = this.context.pureModel.addPrefixToTypeReference(srcAssociation.properties.get(0).type); - String property1Ref = this.context.pureModel.addPrefixToTypeReference(srcAssociation.properties.get(1).type); - - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association association = this.context.pureModel.getAssociation(this.context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name), srcAssociation.sourceInformation); - ProcessingContext ctx = new ProcessingContext("Association " + this.context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name) + " (fourth pass)"); - - ListIterate.collect(srcAssociation.qualifiedProperties, property -> - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(this.context, srcAssociation.properties.get(0).type.equals(property.returnType) ? property1Ref : property0Ref); - ctx.addInferredVariables("this", thisVariable); - ctx.push("Qualified Property " + property.name); - ListIterate.collect(property.parameters, expression -> expression.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx))); - MutableList body = ListIterate.collect(property.body, expression -> expression.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx))); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty prop = association._qualifiedProperties().detect(o -> o._name().equals(property.name)); - ctx.pop(); - ctx.flushVariable("this"); - return prop._expressionSequence(body); - }); - - return association; - } - - @Override - public PackageableElement visit(Function function) - { - return null; - } - - @Override - public PackageableElement visit(Measure measure) - { - return null; - } - - @Override - public PackageableElement visit(Mapping mapping) - { - final org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = this.context.pureModel.getMapping(this.context.pureModel.buildPackageString(mapping._package, mapping.name), mapping.sourceInformation); - if (mapping.classMappings != null && pureMapping._classMappings().isEmpty()) - { - RichIterable>> setImplementations = ListIterate.collect(mapping.classMappings, cm -> cm.accept(new ClassMappingFirstPassBuilder(this.context, pureMapping))); - pureMapping._classMappingsAddAll(setImplementations.flatCollect(p -> Lists.mutable.with(p.getOne()).withAll(p.getTwo()))); - } - if (!mapping.tests.isEmpty()) - { - mapping.tests.forEach(t -> HelperMappingBuilder.processMappingTest(t, this.context)); - } - if (mapping.testSuites != null) - { - TestBuilderHelper.validateTestSuiteIdsList(mapping.testSuites, mapping.sourceInformation); - pureMapping._tests(ListIterate.collect(mapping.testSuites, suite -> HelperMappingBuilder.processMappingTestAndTestSuite(suite, pureMapping, this.context))); - } - return pureMapping; - } - - @Override - public PackageableElement visit(PackageableRuntime packageableRuntime) - { - return null; - } - - @Override - public PackageableElement visit(PackageableConnection packageableConnection) - { - return null; - } - - @Override - public PackageableElement visit(SectionIndex sectionIndex) - { - return null; - } - - @Override - public PackageableElement visit(DataElement dataElement) - { - return null; - } -} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementThirdPassBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementMilestoningPassBuilder.java similarity index 92% rename from legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementThirdPassBuilder.java rename to legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementMilestoningPassBuilder.java index 44a180f065a..681b9898e73 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementThirdPassBuilder.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementMilestoningPassBuilder.java @@ -1,4 +1,4 @@ -// Copyright 2020 Goldman Sachs +// Copyright 2024 Goldman Sachs // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -28,12 +28,13 @@ import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property; -public class PackageableElementThirdPassBuilder implements PackageableElementVisitor +public class PackageableElementMilestoningPassBuilder implements PackageableElementVisitor { private final CompileContext context; - public PackageableElementThirdPassBuilder(CompileContext context) + public PackageableElementMilestoningPassBuilder(CompileContext context) { this.context = context; } @@ -41,7 +42,6 @@ public PackageableElementThirdPassBuilder(CompileContext context) @Override public PackageableElement visit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) { - this.context.getExtraProcessorOrThrow(element).processThirdPass(element, this.context); return null; } @@ -77,7 +77,7 @@ public PackageableElement visit(Association srcAssociation) org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class class1 = this.context.resolveClass(property0Ref, srcAssociation.properties.get(0).sourceInformation); org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class class2 = this.context.resolveClass(property1Ref, srcAssociation.properties.get(1).sourceInformation); - MutableList> properties = association._properties().toList(); + MutableList> properties = association._properties().toList(); MutableList> originalMilestonedProperties = association._originalMilestonedProperties().toList(); MutableList> qualifiedProperties = association._qualifiedProperties().toList(); @@ -114,25 +114,25 @@ public PackageableElement visit(Measure measure) } @Override - public PackageableElement visit(Mapping mapping) + public PackageableElement visit(SectionIndex sectionIndex) { return null; } @Override - public PackageableElement visit(PackageableRuntime packageableRuntime) + public PackageableElement visit(Mapping mapping) { return null; } @Override - public PackageableElement visit(PackageableConnection packageableConnection) + public PackageableElement visit(PackageableRuntime packageableRuntime) { return null; } @Override - public PackageableElement visit(SectionIndex sectionIndex) + public PackageableElement visit(PackageableConnection packageableConnection) { return null; } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementSecondPassBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementSecondPassBuilder.java deleted file mode 100644 index f6464d12e54..00000000000 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementSecondPassBuilder.java +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright 2020 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. - -package org.finos.legend.engine.language.pure.compiler.toPureGraph; - -import org.eclipse.collections.api.RichIterable; -import org.eclipse.collections.api.factory.Lists; -import org.eclipse.collections.api.factory.Sets; -import org.eclipse.collections.api.list.ListIterable; -import org.eclipse.collections.api.list.MutableList; -import org.eclipse.collections.impl.utility.ListIterate; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.data.EmbeddedDataFirstPassBuilder; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtensions; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.IncludedMappingHandler; -import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; -import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; -import org.finos.legend.pure.generated.Root_meta_core_runtime_Connection; -import org.finos.legend.pure.generated.Root_meta_pure_data_DataElement; -import org.finos.legend.pure.generated.Root_meta_pure_data_DataElementReference; -import org.finos.legend.pure.generated.Root_meta_pure_data_EmbeddedData; -import org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification; - -import java.util.Set; - -public class PackageableElementSecondPassBuilder implements PackageableElementVisitor -{ - private final CompileContext context; - - public PackageableElementSecondPassBuilder(CompileContext context) - { - this.context = context; - } - - @Override - public PackageableElement visit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) - { - this.context.getExtraProcessorOrThrow(element).processSecondPass(element, this.context); - return null; - } - - @Override - public PackageableElement visit(Profile profile) - { - return null; - } - - @Override - public PackageableElement visit(Enumeration _enum) - { - return null; - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public PackageableElement visit(Class srcClass) - { - String fullPath = this.context.pureModel.buildPackageString(srcClass._package, srcClass.name); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class _class = this.context.pureModel.getClass(fullPath, srcClass.sourceInformation); - GenericType _classGenericType = this.context.resolveGenericType(fullPath, srcClass.sourceInformation); - Set uniqueSuperTypes = Sets.mutable.empty(); - MutableList generalization = ListIterate.collect(srcClass.superTypes, superTypePtr -> - { - String superType = superTypePtr.path; - // validate no duplicated class supertype - if (!uniqueSuperTypes.add(superType)) - { - throw new EngineException("Duplicated super type '" + superType + "' in class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "'", srcClass.sourceInformation, EngineErrorType.COMPILATION); - } - Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("", SourceInformationHelper.toM3SourceInformation(superTypePtr.sourceInformation), this.context.pureModel.getClass("meta::pure::metamodel::relationship::Generalization"))._general(this.context.resolveGenericType(superType, superTypePtr.sourceInformation))._specific(_class); - if (!this.context.pureModel.isImmutable(superType)) - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class superTypeClass; - Type type = this.context.resolveType(superType, superTypePtr.sourceInformation); - try - { - superTypeClass = (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) type; - } - catch (ClassCastException e) - { - throw new EngineException("Invalid supertype: '" + srcClass.name + "' cannot extend '" + superType + "' as it is not a class.", srcClass.sourceInformation, EngineErrorType.COMPILATION); - } - synchronized (superTypeClass) - { - superTypeClass._specializationsAdd(g); - } - } - return g; - }); - - MutableList> properties = ListIterate.collect(srcClass.properties, HelperModelBuilder.processProperty(this.context, _classGenericType, _class)); - MutableList> restrictedMilestoningProperties = Milestoning.restrictedMilestoningProperties(_class, srcClass, properties, this.context.pureModel); - MutableList> withMilestoningProperties = properties.select(p -> !restrictedMilestoningProperties.contains(p)).withAll(Milestoning.generateMilestoningProperties(_class, this.context)); - - ProcessingContext ctx = new ProcessingContext("Class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' Second Pass"); - ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(this.context, this.context.pureModel.buildPackageString(srcClass._package, srcClass.name)); - ctx.addInferredVariables("this", thisVariable); - - RichIterable> qualifiedProperties = ListIterate.collect(srcClass.qualifiedProperties, HelperModelBuilder.processQualifiedPropertyFirstPass(this.context, _class, this.context.pureModel.buildPackageString(srcClass._package, srcClass.name), ctx)); - _class._originalMilestonedProperties(ListIterate.collect(srcClass.originalMilestonedProperties, HelperModelBuilder.processProperty(this.context, _classGenericType, _class))) - ._generalizations(generalization) - ._qualifiedProperties(qualifiedProperties) - ._properties(withMilestoningProperties); - if (_class._generalizations().isEmpty()) - { - Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("", null, this.context.pureModel.getClass("meta::pure::metamodel::relationship::Generalization")) - ._general(this.context.pureModel.getGenericType("meta::pure::metamodel::type::Any")) - ._specific(_class); - _class._generalizationsAdd(g); - } - ctx.flushVariable("this"); - return _class; - } - - @Override - public PackageableElement visit(Association srcAssociation) - { - String packageString = this.context.pureModel.buildPackageString(srcAssociation._package, srcAssociation.name); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association association = this.context.pureModel.getAssociation(packageString, srcAssociation.sourceInformation); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class source = this.context.resolveClass(srcAssociation.properties.get(0).type, srcAssociation.properties.get(0).sourceInformation); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class target = this.context.resolveClass(srcAssociation.properties.get(1).type, srcAssociation.properties.get(1).sourceInformation); - - String property0Ref = this.context.pureModel.addPrefixToTypeReference(HelperModelBuilder.getElementFullPath(source, this.context.pureModel.getExecutionSupport())); - String property1Ref = this.context.pureModel.addPrefixToTypeReference(HelperModelBuilder.getElementFullPath(target, this.context.pureModel.getExecutionSupport())); - - // TODO generalize this validation to all platform/core types - if ("meta::pure::metamodel::type::Any".equals(org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement.getUserPathForPackageableElement(source)) || - "meta::pure::metamodel::type::Any".equals(org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement.getUserPathForPackageableElement(target))) - { - throw new EngineException("Associations to Any are not allowed. Found in '" + packageString + "'", srcAssociation.sourceInformation, EngineErrorType.COMPILATION); - } - - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property property1 = HelperModelBuilder.processProperty(this.context, this.context.pureModel.getGenericTypeFromIndex(property1Ref), association).valueOf(srcAssociation.properties.get(0)); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property property2 = HelperModelBuilder.processProperty(this.context, this.context.pureModel.getGenericTypeFromIndex(property0Ref), association).valueOf(srcAssociation.properties.get(1)); - - synchronized (source) - { - source._propertiesFromAssociationsAdd(property2); - } - synchronized (target) - { - target._propertiesFromAssociationsAdd(property1); - } - - ProcessingContext ctx = new ProcessingContext("Association " + packageString + " (second pass)"); - - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(this.context, property1Ref); - ctx.addInferredVariables("this", thisVariable); - - ListIterable> qualifiedProperties = ListIterate.collect(srcAssociation.qualifiedProperties, p -> - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class cl = this.context.resolveGenericType(p.returnType, p.sourceInformation)._rawType() == source ? target : source; - return HelperModelBuilder.processQualifiedPropertyFirstPass(this.context, association, org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement.getUserPathForPackageableElement(cl), ctx).valueOf(p); - }); - qualifiedProperties.forEach(q -> - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class _class = q._genericType()._rawType() == source ? target : source; - synchronized (_class) - { - _class._qualifiedPropertiesFromAssociationsAdd(q); - } - }); - ctx.flushVariable("this"); - return association._originalMilestonedProperties(ListIterate.collect(srcAssociation.originalMilestonedProperties, HelperModelBuilder.processProperty(this.context, this.context.pureModel.getGenericTypeFromIndex(srcAssociation.properties.get(0).type), association))) - ._properties(Lists.mutable.with(property1, property2)) - ._qualifiedProperties(qualifiedProperties); - } - - @Override - public PackageableElement visit(Function function) - { - return null; - } - - @Override - public PackageableElement visit(Measure measure) - { - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Measure targetMeasure = this.context.pureModel.getMeasure(this.context.pureModel.buildPackageString(measure._package, measure.name), measure.sourceInformation); - if (measure.canonicalUnit != null) - { - targetMeasure._canonicalUnit(HelperMeasureBuilder.processUnitPackageableElementSecondPass(measure.canonicalUnit, this.context)); - } - targetMeasure._nonCanonicalUnits(ListIterate.collect(measure.nonCanonicalUnits, ncu -> HelperMeasureBuilder.processUnitPackageableElementSecondPass(ncu, this.context))); - return targetMeasure; - } - - @Override - public PackageableElement visit(Mapping mapping) - { - final org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = this.context.pureModel.getMapping(this.context.pureModel.buildPackageString(mapping._package, mapping.name), mapping.sourceInformation); - RichIterable> enumerationMappings = ListIterate.collect(mapping.enumerationMappings, em -> HelperMappingBuilder.processEnumMapping(em, pureMapping, this.context)); - if (enumerationMappings.isEmpty() && mapping.includedMappings.isEmpty()) - { - return pureMapping; - } - if (!mapping.includedMappings.isEmpty()) - { - CompilerExtensions extensions = context.pureModel.extensions; - RichIterable mappingIncludes = - ListIterate.collect(mapping.includedMappings, i -> - { - IncludedMappingHandler handler = extensions.getExtraIncludedMappingHandlers(i.getClass().getName()); - return handler.processMappingInclude(i, this.context, pureMapping, - handler.resolveMapping(i, this.context)); - }); - pureMapping._includesAddAll(mappingIncludes); - // validate no duplicated included mappings - Set uniqueMappingIncludes = Sets.mutable.empty(); - mappingIncludes.forEach(includedMapping -> - { - String mappingName = IncludedMappingHandler.parseIncludedMappingNameRecursively(includedMapping); - if (!uniqueMappingIncludes.add(mappingName)) - { - throw new EngineException("Duplicated mapping include '" + mappingName + - "' in " + "mapping " + - "'" + this.context.pureModel.buildPackageString(mapping._package, mapping.name) + "'", mapping.sourceInformation, EngineErrorType.COMPILATION); - } - }); - } - pureMapping._enumerationMappings(enumerationMappings); - return pureMapping; - } - - @Override - public PackageableElement visit(PackageableRuntime packageableRuntime) - { - return null; - } - - @Override - public PackageableElement visit(PackageableConnection packageableConnection) - { - final Root_meta_core_runtime_Connection pureConnection = this.context.pureModel.getConnection(this.context.pureModel.buildPackageString(packageableConnection._package, packageableConnection.name), packageableConnection.sourceInformation); - packageableConnection.connectionValue.accept(new ConnectionSecondPassBuilder(this.context, pureConnection)); - return null; - } - - @Override - public PackageableElement visit(SectionIndex sectionIndex) - { - return null; - } - - @Override - public PackageableElement visit(DataElement dataElement) - { - String fullPath = context.pureModel.buildPackageString(dataElement._package, dataElement.name); - Root_meta_pure_data_DataElement compiled = (Root_meta_pure_data_DataElement) context.pureModel.getPackageableElement(fullPath); - - ProcessingContext processingContext = new ProcessingContext("Data '" + fullPath + "' Second Pass"); - Root_meta_pure_data_EmbeddedData compiledData = dataElement.data.accept(new EmbeddedDataFirstPassBuilder(context, processingContext)); - if (compiledData instanceof Root_meta_pure_data_DataElementReference) - { - throw new EngineException("Cannot use Data element reference in a Data element", dataElement.data.sourceInformation, EngineErrorType.COMPILATION); - } - compiled._data(compiledData); - return null; - } -} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementSixthPassBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementSixthPassBuilder.java deleted file mode 100644 index d2c30528fe7..00000000000 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableElementSixthPassBuilder.java +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.language.pure.compiler.toPureGraph; - -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; - -public class PackageableElementSixthPassBuilder implements PackageableElementVisitor -{ - private final CompileContext context; - - public PackageableElementSixthPassBuilder(CompileContext context) - { - this.context = context; - } - - @Override - public PackageableElement visit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) - { - this.context.getExtraProcessorOrThrow(element).processSixthPass(element, this.context); - return null; - } - - @Override - public PackageableElement visit(Profile profile) - { - return null; - } - - @Override - public PackageableElement visit(Enumeration _enum) - { - return null; - } - - @Override - public PackageableElement visit(Class srcClass) - { - return null; - } - - @Override - public PackageableElement visit(Association srcAssociation) - { - return null; - } - - @Override - public PackageableElement visit(Function function) - { - return null; - } - - @Override - public PackageableElement visit(Measure measure) - { - return null; - } - - @Override - public PackageableElement visit(Mapping mapping) - { - final org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping pureMapping = this.context.pureModel.getMapping(this.context.pureModel.buildPackageString(mapping._package, mapping.name), mapping.sourceInformation); - if (mapping.classMappings != null) - { - mapping.classMappings.forEach(cm -> cm.accept(new ClassMappingThirdPassBuilder(this.context, pureMapping))); - } - return pureMapping; - } - - @Override - public PackageableElement visit(PackageableRuntime packageableRuntime) - { - return null; - } - - @Override - public PackageableElement visit(PackageableConnection packageableConnection) - { - return null; - } - - @Override - public PackageableElement visit(SectionIndex sectionIndex) - { - return null; - } - - @Override - public PackageableElement visit(DataElement dataElement) - { - return null; - } -} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableRuntimeCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableRuntimeCompilerExtension.java new file mode 100644 index 00000000000..5192b294631 --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PackageableRuntimeCompilerExtension.java @@ -0,0 +1,76 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; +import org.finos.legend.pure.generated.Root_meta_core_runtime_EngineRuntime; +import org.finos.legend.pure.generated.Root_meta_core_runtime_EngineRuntime_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableRuntime; +import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableRuntime_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; + +public class PackageableRuntimeCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "PackageableRuntime"); + } + + @Override + public CompilerExtension build() + { + return new PackageableRuntimeCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + PackageableRuntime.class, + Lists.fixedSize.with(Mapping.class, PackageableConnection.class), + this::packageableRuntimeFirstPass, + (PackageableRuntime packageableRuntime, CompileContext context) -> + { + }, + this::packageableRuntimeThirdPass + ) + ); + } + + private PackageableElement packageableRuntimeFirstPass(PackageableRuntime packageableRuntime, CompileContext context) + { + Root_meta_pure_runtime_PackageableRuntime metamodel = new Root_meta_pure_runtime_PackageableRuntime_Impl(packageableRuntime.name, SourceInformationHelper.toM3SourceInformation(packageableRuntime.sourceInformation), context.pureModel.getClass("meta::pure::runtime::PackageableRuntime")); + GenericType packageableRuntimeGenericType = context.newGenericType(context.pureModel.getType("meta::pure::runtime::PackageableRuntime")); + metamodel._classifierGenericType(packageableRuntimeGenericType); + Root_meta_core_runtime_EngineRuntime pureRuntime = new Root_meta_core_runtime_EngineRuntime_Impl("Root::meta::core::runtime::Runtime", SourceInformationHelper.toM3SourceInformation(packageableRuntime.sourceInformation), context.pureModel.getClass("meta::core::runtime::Runtime")); + return metamodel._runtimeValue(pureRuntime); + } + + private void packageableRuntimeThirdPass(PackageableRuntime packageableRuntime, CompileContext context) + { + String fullPath = context.pureModel.buildPackageString(packageableRuntime._package, packageableRuntime.name); + Root_meta_pure_runtime_PackageableRuntime metamodel = context.pureModel.getPackageableRuntime(fullPath, packageableRuntime.sourceInformation); + HelperRuntimeBuilder.buildEngineRuntime(packageableRuntime.runtimeValue, metamodel._runtimeValue(), context); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/ProfileCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/ProfileCompilerExtension.java new file mode 100644 index 00000000000..1479fe0cf82 --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/ProfileCompilerExtension.java @@ -0,0 +1,76 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_Profile_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_Stereotype_Impl; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_extension_Tag_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Stereotype; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Tag; + +public class ProfileCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "Profile"); + } + + @Override + public CompilerExtension build() + { + return new ProfileCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + Profile.class, + this::profileFirstPass + ) + ); + } + + private PackageableElement profileFirstPass(Profile profile, CompileContext context) + { + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile targetProfile = new Root_meta_pure_metamodel_extension_Profile_Impl(profile.name, SourceInformationHelper.toM3SourceInformation(profile.sourceInformation), context.pureModel.getClass("meta::pure::metamodel::extension::Profile")); + return targetProfile._p_stereotypes(ListIterate.collect(profile.stereotypes, st -> newStereotype(targetProfile, st.value, st.sourceInformation, context))) + ._p_tags(ListIterate.collect(profile.tags, t -> newTag(targetProfile, t.value, t.sourceInformation, context))); + } + + private Stereotype newStereotype(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile profile, String name, SourceInformation sourceInformation, CompileContext context) + { + return new Root_meta_pure_metamodel_extension_Stereotype_Impl(name, SourceInformationHelper.toM3SourceInformation(sourceInformation), context.pureModel.getClass("meta::pure::metamodel::extension::Stereotype")) + ._value(name) + ._profile(profile); + } + + private Tag newTag(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Profile profile, String name, SourceInformation sourceInformation, CompileContext context) + { + return new Root_meta_pure_metamodel_extension_Tag_Impl(name, SourceInformationHelper.toM3SourceInformation(sourceInformation), context.pureModel.getClass("meta::pure::metamodel::extension::Tag")) + ._value(name) + ._profile(profile); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java index 6ce0bdc75f5..81c22411eb0 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java @@ -27,8 +27,10 @@ import org.eclipse.collections.api.map.MutableMap; import org.eclipse.collections.api.set.ImmutableSet; import org.eclipse.collections.api.set.MutableSet; +import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.map.mutable.ConcurrentHashMap; import org.eclipse.collections.impl.multimap.list.FastListMultimap; +import org.eclipse.collections.impl.tuple.Tuples; import org.eclipse.collections.impl.utility.LazyIterate; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.language.pure.compiler.MetadataWrapper; @@ -46,15 +48,7 @@ import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.externalFormat.Binding; -import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.Section; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; import org.finos.legend.engine.shared.core.deployment.DeploymentMode; @@ -73,6 +67,7 @@ import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl; import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableConnection; import org.finos.legend.pure.generated.Root_meta_pure_runtime_PackageableRuntime; +import org.finos.legend.pure.generated.platform_pure_essential_meta_graph_elementToPath; import org.finos.legend.pure.m3.coreinstance.Package; import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PropertyOwner; @@ -114,8 +109,9 @@ import java.lang.reflect.Field; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.ConcurrentLinkedQueue; @@ -127,6 +123,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; +import java.util.stream.StreamSupport; public class PureModel implements IPureModel { @@ -253,53 +250,66 @@ public PureModel(PureModelContextData pureModelContextData, CompilerExtensions e LOGGER.info("{}", new LogInfo(user, "GRAPH_PRE_VALIDATION_COMPLETED", nanosDurationToMillis(preValidationStart, preValidationEnd))); span.log("GRAPH_PRE_VALIDATION_COMPLETED"); - // Processing - long indexStart = System.nanoTime(); - PureModelContextDataIndex pureModelContextDataIndex = index(pureModelContextData); - long indexEnd = System.nanoTime(); - LOGGER.info("{}", new LogInfo(user, "GRAPH_INDEX_INPUT", pureModelContextDataIndex, nanosDurationToMillis(indexStart, indexEnd))); - span.log("GRAPH_INDEX_INPUT"); - List elements = pureModelContextData.getElements(); - FastListMultimap, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement> classToElements = - ListIterate.groupBy(elements, x -> - { - Processor extraProcessor = this.extensions.getExtraProcessor(x); - if (extraProcessor != null) - { - return extraProcessor.getElementClass(); - } - return x.getClass(); - }); + DependencyManagement dependencyManagement = new DependencyManagement(); + FastListMultimap, DependencyManagement.PackageableElementsByDependencyLevel> classToElements = FastListMultimap.newMultimap(); + ListIterate.groupBy(elements, x -> + { + Processor extraProcessor = this.extensions.getExtraProcessor(x); + if (extraProcessor != null) + { + return extraProcessor.getElementClass(); + } + return x.getClass(); + }).forEachKeyMultiValues((clazz, elementsInCurrentClass) -> + { + List> elementAndPathPairs = StreamSupport.stream(elementsInCurrentClass.spliterator(), false) + .map(e -> Tuples.pair(e, buildPackageString(e._package, e.name))) + .collect(Collectors.toList()); + classToElements.putAll(clazz, Lists.fixedSize.with(dependencyManagement.new PackageableElementsByDependencyLevel(elementAndPathPairs))); + }); Runnable runPasses = () -> { - MutableList sectionIndices = classToElements.removeAll(SectionIndex.class); + Optional optionalSectionIndices = classToElements.removeAll(SectionIndex.class).getFirstOptional(); + MutableList sectionIndices = optionalSectionIndices.isPresent() + ? optionalSectionIndices.get().getIndependentElementAndPathPairs().collect(Pair::getOne) + : Lists.fixedSize.empty(); sectionIndices.forEach(sectionIndex -> ((SectionIndex) sectionIndex).sections.forEach(section -> section.elements.forEach(elementPath -> this.sectionsIndex.putIfAbsent(elementPath, section)))); - this.maybeParallel(Stream.concat(sectionIndices.stream(), classToElements.removeAll(Profile.class).stream())) + Optional optionalProfiles = classToElements.removeAll(Profile.class).getFirstOptional(); + MutableList profiles = optionalProfiles.isPresent() + ? optionalProfiles.get().getIndependentElementAndPathPairs().collect(Pair::getOne) + : Lists.fixedSize.empty(); + this.maybeParallel(Stream.concat(sectionIndices.stream(), profiles.stream())) .forEach(handleEngineExceptions(this::processFirstPass)); MutableMap, Collection>> dependencyGraph = Maps.mutable.empty(); - dependencyGraph.put(Class.class, Lists.fixedSize.with(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure.class)); - dependencyGraph.put(Association.class, Lists.fixedSize.with(Class.class)); - dependencyGraph.put(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.class, Lists.fixedSize.with(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration.class, Class.class, Association.class, Binding.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.Store.class)); - dependencyGraph.put(PackageableConnection.class, Lists.fixedSize.with(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.class)); - dependencyGraph.put(PackageableRuntime.class, Lists.fixedSize.with(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.class, PackageableConnection.class)); - dependencyGraph.put(Function.class, Lists.fixedSize.with(DataElement.class, Class.class, Association.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.class, Binding.class)); this.extensions.getExtraProcessors().forEach(x -> dependencyGraph.put(x.getElementClass(), (Collection>) x.getPrerequisiteClasses())); - DependencyManagement dependencyManagement = new DependencyManagement(dependencyGraph); + dependencyManagement.processDependencyGraph(dependencyGraph); MutableMap, Collection>> dependentToDependencies = dependencyManagement.getDependentToDependencies(); dependencyManagement.detectCircularDependency(); MutableSet>> disjointDependencyGraphs = dependencyManagement.getDisjointDependencyGraphs(); + MutableMap, MutableMap>> elementPrerequisitesByClass = forkJoinPool == null ? Maps.mutable.empty() : new ConcurrentHashMap<>(); this.maybeParallel(disjointDependencyGraphs.stream()).forEach(disjointDependencyGraph -> { processPass("firstPass", classToElements, dependentToDependencies, handleEngineExceptions(this::processFirstPass), disjointDependencyGraph); processPass("secondPass", classToElements, dependentToDependencies, handleEngineExceptions(this::processSecondPass), disjointDependencyGraph); - processPass("thirdPass", classToElements, dependentToDependencies, handleEngineExceptions(this::processThirdPass), disjointDependencyGraph); - processPass("fourthPass", classToElements, dependentToDependencies, handleEngineExceptions(this::processFourthPass), disjointDependencyGraph); - processPass("fifthPass", classToElements, dependentToDependencies, handleEngineExceptions(this::processFifthPass), disjointDependencyGraph); - processPass("sixthPass", classToElements, dependentToDependencies, handleEngineExceptions(this::processSixthPass), disjointDependencyGraph); + Stream allElementsInDisjointDependencyGraph = disjointDependencyGraph.stream() + .flatMap(clazz -> classToElements.get(clazz).flatCollect(elementsInThisClass -> elementsInThisClass.getIndependentElementAndPathPairs().collect(Pair::getOne)).stream()); + this.maybeParallel(allElementsInDisjointDependencyGraph).forEach(element -> + { + java.lang.Class elementClass = element.getClass(); + String elementFullPath = buildPackageString(element._package, element.name); + RichIterable prerequisiteElements = processPrerequisiteElementsPass(element); + MutableSet prerequisiteElementFullPaths = Sets.fixedSize.withAll(prerequisiteElements.collect(prerequisiteElement -> + platform_pure_essential_meta_graph_elementToPath.Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_(prerequisiteElement, getExecutionSupport()))); + elementPrerequisitesByClass.putIfAbsent(elementClass, forkJoinPool == null ? Maps.mutable.empty() : new ConcurrentHashMap<>()); + elementPrerequisitesByClass.get(elementClass).put(elementFullPath, prerequisiteElementFullPaths); + }); + FastListMultimap, DependencyManagement.PackageableElementsByDependencyLevel> classToElementsSortedByDependencyLevel = dependencyManagement.topologicallySortElements(classToElements, elementPrerequisitesByClass); + processPass("milestoningPass", classToElementsSortedByDependencyLevel, dependentToDependencies, handleEngineExceptions(this::processMilestoningPass), disjointDependencyGraph); + processPass("thirdPass", classToElementsSortedByDependencyLevel, dependentToDependencies, handleEngineExceptions(this::processThirdPass), disjointDependencyGraph); }); }; @@ -528,13 +538,13 @@ private Consumer, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement> classToElements, MutableMap, Collection>> dependentToDependencies, Consumer passConsumer, MutableSet> disjointDependencyGraph) + private void processPass(String name, FastListMultimap, DependencyManagement.PackageableElementsByDependencyLevel> classToElements, MutableMap, Collection>> dependentToDependencies, Consumer passConsumer, MutableSet> disjointDependencyGraph) { MutableMap, CompletableFuture> tracker = Maps.mutable.empty(); disjointDependencyGraph.forEach(dependent -> tracker.put(dependent, new CompletableFuture<>())); this.maybeParallel(disjointDependencyGraph.stream()).forEach(dependent -> { - MutableList elementsToCompile = classToElements.get(dependent); + MutableList allElementsByDependencyLevel = classToElements.get(dependent); CompletableFuture allDependencyFutures = CompletableFuture.allOf(dependentToDependencies.get(dependent) .stream() @@ -544,7 +554,7 @@ private void processPass(String name, FastListMultimap this.maybeParallel(elementsInCurrentDependencyLevel.getIndependentElementAndPathPairs().collect(Pair::getOne).stream()).forEach(passConsumer)); tracker.get(dependent).complete(null); LOGGER.debug("{} - Completed {}", name, dependent); } @@ -583,41 +593,48 @@ else if (cause instanceof RuntimeException) } } - private org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement processFirstPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + private void processFirstPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) { - return visitWithErrorHandling(element, new PackageableElementFirstPassBuilder(getContext(element))); + visitWithErrorHandling(element, () -> + { + getContext(element).processFirstPass(element); + return null; + }); } private void processSecondPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) { - visitWithErrorHandling(element, new PackageableElementSecondPassBuilder(getContext(element))); - } - - private void processThirdPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) - { - visitWithErrorHandling(element, new PackageableElementThirdPassBuilder(getContext(element))); + visitWithErrorHandling(element, () -> + { + getContext(element).processSecondPass(element); + return null; + }); } - private void processFourthPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + private RichIterable processPrerequisiteElementsPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) { - visitWithErrorHandling(element, new PackageableElementFourthPassBuilder(getContext(element))); + return visitWithErrorHandling(element, () -> getContext(element).processPrerequisiteElementsPass(element)); } - private void processFifthPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + private void processMilestoningPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) { - visitWithErrorHandling(element, new PackageableElementFifthPassBuilder(getContext(element))); + visitWithErrorHandling(element, () -> element.accept(new PackageableElementMilestoningPassBuilder(getContext(element)))); } - private void processSixthPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) + private void processThirdPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element) { - visitWithErrorHandling(element, new PackageableElementSixthPassBuilder(getContext(element))); + visitWithErrorHandling(element, () -> + { + getContext(element).processThirdPass(element); + return null; + }); } - private T visitWithErrorHandling(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element, PackageableElementVisitor visitor) + private T visitWithErrorHandling(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement element, Callable callable) { try { - return element.accept(visitor); + return callable.call(); } catch (Exception e) { @@ -626,7 +643,7 @@ private T visitWithErrorHandling(org.finos.legend.engine.protocol.pure.v1.mo SourceInformation sourceInformation = ((EngineException) e).getSourceInformation(); if ((sourceInformation != null) && (sourceInformation != SourceInformation.getUnknownSourceInformation())) { - throw e; + throw (EngineException) e; } } StringBuilder builder = new StringBuilder("Error in '").append(element.getPath()).append("'"); @@ -1427,125 +1444,6 @@ public Handlers getHandlers() return handlers; } - private PureModelContextDataIndex index(PureModelContextData pureModelContextData) - { - PureModelContextDataIndex index = new PureModelContextDataIndex(); - MutableMap, - MutableList> stores = Maps.mutable.empty(); - - MutableMap, - MutableList> otherElementsByClass = Maps.mutable.empty(); - pureModelContextData.getElements().forEach(e -> - { - if (e instanceof Association) - { - index.associations.add((Association) e); - } - else if (e instanceof Class) - { - index.classes.add((Class) e); - } - else if (e instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration) - { - index.enumerations.add((org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration) e); - } - else if (e instanceof Function) - { - index.functions.add((Function) e); - } - else if (e instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping) - { - index.mappings.add((org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping) e); - } - else if (e instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure) - { - index.measures.add((org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure) e); - } - else if (e instanceof PackageableConnection) - { - index.connections.add((PackageableConnection) e); - } - else if (e instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime) - { - index.runtimes.add((org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime) e); - } - else if (e instanceof Profile) - { - index.profiles.add((Profile) e); - } - else if (e instanceof SectionIndex) - { - index.sectionIndices.add((SectionIndex) e); - } - else if (e instanceof DataElement) - { - index.dataElements.add((DataElement) e); - } - // TODO eliminate special handling for stores - else if (e instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.Store) - { - stores.getIfAbsentPut(e.getClass(), Lists.mutable::empty).add((org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.Store) e); - } - else - { - otherElementsByClass.getIfAbsentPut(e.getClass(), Lists.mutable::empty).add(e); - } - }); - stores.forEach((cls, elements) -> index.stores.getIfAbsentPut(this.extensions.getExtraProcessorOrThrow(cls), Lists.mutable::empty).addAll(elements)); - otherElementsByClass.forEach((cls, elements) -> index.otherElementsByProcessor.getIfAbsentPut(this.extensions.getExtraProcessorOrThrow(cls), Lists.mutable::empty).addAll(elements)); - return index; - } - - private static class PureModelContextDataIndex - { - private final MutableList associations = Lists.mutable.empty(); - private final MutableList classes = Lists.mutable.empty(); - private final MutableList enumerations = Lists.mutable.empty(); - private final MutableList functions = Lists.mutable.empty(); - private final MutableList mappings = Lists.mutable.empty(); - private final MutableList measures = Lists.mutable.empty(); - private final MutableList connections = Lists.mutable.empty(); - private final MutableList runtimes = Lists.mutable.empty(); - private final MutableList profiles = Lists.mutable.empty(); - private final MutableList sectionIndices = Lists.mutable.empty(); - private final MutableList dataElements = Lists.mutable.empty(); - private final MutableMap, MutableList> stores = Maps.mutable.empty(); - private final MutableMap, MutableList> otherElementsByProcessor = Maps.mutable.empty(); - - public Map getStats() - { - MutableMap result = Maps.mutable.empty(); - possiblyAddStats(result, "associations", this.associations); - possiblyAddStats(result, "classes", this.classes); - possiblyAddStats(result, "enumerations", this.enumerations); - possiblyAddStats(result, "functions", this.functions); - possiblyAddStats(result, "mappings", this.mappings); - possiblyAddStats(result, "measures", this.measures); - possiblyAddStats(result, "connections", this.connections); - possiblyAddStats(result, "runtimes", this.runtimes); - possiblyAddStats(result, "profiles", this.profiles); - possiblyAddStats(result, "sectionIndices", this.sectionIndices); - possiblyAddStats(result, "dataElements", this.dataElements); - if (this.stores.notEmpty()) - { - result.put("stores", this.stores.valuesView().sumOfInt(MutableList::size)); - } - if (this.otherElementsByProcessor.notEmpty()) - { - result.put("otherElements", this.otherElementsByProcessor.valuesView().sumOfInt(MutableList::size)); - } - return result; - } - - private static void possiblyAddStats(MutableMap stats, String name, MutableList list) - { - if (list.notEmpty()) - { - stats.put(name, list.size()); - } - } - } - private static double nanosDurationToMillis(long startNanos, long endNanos) { return (endNanos - startNanos) / 1_000_000.0d; diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/SectionIndexCompilerExtension.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/SectionIndexCompilerExtension.java new file mode 100644 index 00000000000..f00c53999c8 --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/SectionIndexCompilerExtension.java @@ -0,0 +1,54 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.MutableList; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; +import org.finos.legend.pure.generated.Root_meta_pure_metamodel_section_SectionIndex_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; + +public class SectionIndexCompilerExtension implements CompilerExtension +{ + @Override + public MutableList group() + { + return org.eclipse.collections.impl.factory.Lists.mutable.with("PackageableElement", "SectionIndex"); + } + + @Override + public CompilerExtension build() + { + return new SectionIndexCompilerExtension(); + } + + @Override + public Iterable> getExtraProcessors() + { + return Lists.fixedSize.of( + Processor.newProcessor( + SectionIndex.class, + this::sectionIndexFirstPass + ) + ); + } + + private PackageableElement sectionIndexFirstPass(SectionIndex sectionIndex, CompileContext context) + { + return new Root_meta_pure_metamodel_section_SectionIndex_Impl(sectionIndex.name, SourceInformationHelper.toM3SourceInformation(sectionIndex.sourceInformation), context.pureModel.getClass("meta::pure::metamodel::section::SectionIndex")); + } +} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/CompilerExtensions.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/CompilerExtensions.java index 5f481244ff6..1218016058d 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/CompilerExtensions.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/CompilerExtensions.java @@ -88,15 +88,6 @@ public class CompilerExtensions @SuppressWarnings("unchecked") private static final ImmutableSet> FORBIDDEN_PROCESSOR_CLASSES = Sets.immutable.with( PackageableElement.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Association.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Enumeration.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Measure.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Profile.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime.class, - org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.Store.class ); diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/Processor.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/Processor.java index c5b99a5e4a2..1c0bc327012 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/Processor.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/extension/Processor.java @@ -14,6 +14,8 @@ package org.finos.legend.engine.language.pure.compiler.toPureGraph.extension; +import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Lists; import org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; @@ -31,6 +33,11 @@ public Collection> getPrerequisite return Collections.emptyList(); } + public RichIterable getPrerequisiteElements(PackageableElement element, CompileContext context) + { + return processPrerequisiteElements(castElement(element), context); + } + public final org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement processFirstPass(PackageableElement element, CompileContext context) { return processElementFirstPass(castElement(element), context); @@ -46,21 +53,6 @@ public final void processThirdPass(PackageableElement element, CompileContext co processElementThirdPass(castElement(element), context); } - public final void processFourthPass(PackageableElement element, CompileContext context) - { - processElementFourthPass(castElement(element), context); - } - - public final void processFifthPass(PackageableElement element, CompileContext context) - { - processElementFifthPass(castElement(element), context); - } - - public final void processSixthPass(PackageableElement element, CompileContext context) - { - processElementSixthPass(castElement(element), context); - } - @Override public final boolean equals(Object other) { @@ -79,6 +71,8 @@ public String toString() return ""; } + protected abstract RichIterable processPrerequisiteElements(T element, CompileContext context); + protected abstract org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement processElementFirstPass(T element, CompileContext context); protected void processElementSecondPass(T element, CompileContext context) @@ -91,22 +85,6 @@ protected void processElementThirdPass(T element, CompileContext context) // nothing by default } - protected void processElementFourthPass(T element, CompileContext context) - { - // nothing by default - } - - protected void processElementFifthPass(T element, CompileContext context) - { - // nothing by default - } - - protected void processElementSixthPass(T element, CompileContext context) - { - // nothing by default - } - - private T castElement(PackageableElement element) { return getElementClass().cast(element); @@ -134,6 +112,12 @@ public Collection> getPrerequisite return resolvedPrerequisiteClasses; } + @Override + protected RichIterable processPrerequisiteElements(T element, CompileContext context) + { + return Lists.fixedSize.empty(); + } + @Override protected org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement processElementFirstPass(T element, CompileContext context) { @@ -154,7 +138,7 @@ public static Processor newProcessor(Class BiFunction firstPass, BiConsumer secondPass) { - return newProcessor(elementClass, prerequisiteClasses, firstPass, secondPass, null, null, null); + return newProcessor(elementClass, prerequisiteClasses, firstPass, secondPass, null, null); } public static Processor newProcessor(Class elementClass, @@ -162,7 +146,7 @@ public static Processor newProcessor(Class BiConsumer secondPass, BiConsumer thirdPass) { - return newProcessor(elementClass, null, firstPass, secondPass, thirdPass); + return newProcessor(elementClass, null, firstPass, secondPass, thirdPass, null); } public static Processor newProcessor(Class elementClass, @@ -171,16 +155,16 @@ public static Processor newProcessor(Class BiConsumer secondPass, BiConsumer thirdPass) { - return newProcessor(elementClass, prerequisiteClasses, firstPass, secondPass, thirdPass, null, null); + return newProcessor(elementClass, prerequisiteClasses, firstPass, secondPass, thirdPass, null); } public static Processor newProcessor(Class elementClass, BiFunction firstPass, BiConsumer secondPass, BiConsumer thirdPass, - BiConsumer fourthPass) + BiFunction> prerequisiteElementsPass) { - return newProcessor(elementClass, null, firstPass, secondPass, thirdPass, fourthPass); + return newProcessor(elementClass, null, firstPass, secondPass, thirdPass, prerequisiteElementsPass); } public static Processor newProcessor(Class elementClass, @@ -188,28 +172,7 @@ public static Processor newProcessor(Class BiFunction firstPass, BiConsumer secondPass, BiConsumer thirdPass, - BiConsumer fourthPass) - { - return newProcessor(elementClass, prerequisiteClasses, firstPass, secondPass, thirdPass, fourthPass, null); - } - - public static Processor newProcessor(Class elementClass, - BiFunction firstPass, - BiConsumer secondPass, - BiConsumer thirdPass, - BiConsumer fourthPass, - BiConsumer fifthPass) - { - return newProcessor(elementClass, null, firstPass, secondPass, thirdPass, fourthPass, fifthPass); - } - - public static Processor newProcessor(Class elementClass, - Collection> prerequisiteClasses, - BiFunction firstPass, - BiConsumer secondPass, - BiConsumer thirdPass, - BiConsumer fourthPass, - BiConsumer fifthPass) + BiFunction> prerequisiteElementsPass) { Collection> resolvedPrerequisiteClasses = (prerequisiteClasses == null) ? Collections.emptyList() : prerequisiteClasses; return new Processor() @@ -227,71 +190,13 @@ public Collection> getPrerequisite } @Override - protected org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement processElementFirstPass(T element, CompileContext context) - { - return firstPass.apply(element, context); - } - - @Override - protected void processElementSecondPass(T element, CompileContext context) - { - if (secondPass != null) - { - secondPass.accept(element, context); - } - } - - @Override - protected void processElementThirdPass(T element, CompileContext context) + protected RichIterable processPrerequisiteElements(T element, CompileContext context) { - if (thirdPass != null) + if (prerequisiteElementsPass != null) { - thirdPass.accept(element, context); + return prerequisiteElementsPass.apply(element, context); } - } - - @Override - protected void processElementFourthPass(T element, CompileContext context) - { - if (fourthPass != null) - { - fourthPass.accept(element, context); - } - } - - @Override - protected void processElementFifthPass(T element, CompileContext context) - { - if (fifthPass != null) - { - fifthPass.accept(element, context); - } - } - }; - } - - public static Processor newProcessor(Class elementClass, - Collection> prerequisiteClasses, - BiFunction firstPass, - BiConsumer secondPass, - BiConsumer thirdPass, - BiConsumer fourthPass, - BiConsumer fifthPass, - BiConsumer sixthPass) - { - Collection> resolvedPrerequisiteClasses = (prerequisiteClasses == null) ? Collections.emptyList() : prerequisiteClasses; - return new Processor() - { - @Override - public Class getElementClass() - { - return elementClass; - } - - @Override - public Collection> getPrerequisiteClasses() - { - return resolvedPrerequisiteClasses; + return Lists.fixedSize.empty(); } @Override @@ -317,33 +222,6 @@ protected void processElementThirdPass(T element, CompileContext context) thirdPass.accept(element, context); } } - - @Override - protected void processElementFourthPass(T element, CompileContext context) - { - if (fourthPass != null) - { - fourthPass.accept(element, context); - } - } - - @Override - protected void processElementFifthPass(T element, CompileContext context) - { - if (fifthPass != null) - { - fifthPass.accept(element, context); - } - } - - @Override - protected void processElementSixthPass(T element, CompileContext context) - { - if (sixthPass != null) - { - sixthPass.accept(element, context); - } - } }; } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/resources/META-INF/services/org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/resources/META-INF/services/org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension index 526218db8fe..befdfd77628 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/resources/META-INF/services/org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/resources/META-INF/services/org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension @@ -1 +1,12 @@ -org.finos.legend.engine.language.pure.compiler.toPureGraph.CoreCompilerExtension \ No newline at end of file +org.finos.legend.engine.language.pure.compiler.toPureGraph.CoreCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.ProfileCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.EnumerationCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.ClassCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.MeasureCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.AssociationCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.FunctionCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.MappingCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableRuntimeCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableConnectionCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.SectionIndexCompilerExtension +org.finos.legend.engine.language.pure.compiler.toPureGraph.DataElementCompilerExtension \ No newline at end of file diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestDomainCompilationFromGrammar.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestDomainCompilationFromGrammar.java index d0ca1a20959..10d89844894 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestDomainCompilationFromGrammar.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestDomainCompilationFromGrammar.java @@ -1515,12 +1515,12 @@ public void testMultiplicityErrorInCollection() "{\n" + " names : String[*];\n" + " prop() {$this.names + 'ok'} : String[1];\n" + - "}", "COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Fourth Pass, Qualified Property prop, Applying plus], multiplicity:[*]"); + "}", "COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Third Pass, Qualified Property prop, Applying plus], multiplicity:[*]"); test("Class test::A\n" + "{\n" + " names : String[0..1];\n" + " prop() {$this.names + 'ok'} : String[1];\n" + - "}", "COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Fourth Pass, Qualified Property prop, Applying plus], multiplicity:[0..1]"); + "}", "COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Third Pass, Qualified Property prop, Applying plus], multiplicity:[0..1]"); } @Test @@ -1555,7 +1555,7 @@ public void testPartialCompilationMultiplicityErrorInCollectionAndConstraint() "{\n" + " names : String[*];\n" + " prop() {$this.names + 'ok'} : String[1];\n" + - "}", Lists.fixedSize.with("COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Fourth Pass, Qualified Property prop, Applying plus], multiplicity:[*]")); + "}", Lists.fixedSize.with("COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Third Pass, Qualified Property prop, Applying plus], multiplicity:[*]")); partialCompilationTest("Class test::A\n" + "{\n" + @@ -1568,7 +1568,7 @@ public void testPartialCompilationMultiplicityErrorInCollectionAndConstraint() "]\n" + "{\n" + " names : String[*];\n" + - "}", Lists.fixedSize.with("COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Fourth Pass, Qualified Property prop, Applying plus], multiplicity:[0..1]", "COMPILATION error at [8:17-18]: Constraint must be of type 'Boolean'")); + "}", Lists.fixedSize.with("COMPILATION error at [4:18-22]: Collection element must have a multiplicity [1] - Context:[Class 'test::A' Third Pass, Qualified Property prop, Applying plus], multiplicity:[0..1]", "COMPILATION error at [8:17-18]: Constraint must be of type 'Boolean'")); } @Test @@ -1667,7 +1667,7 @@ public void testPropertyPostFunction() public void testUnknownFunction() { test("Class test::Person[$this.lastName->ranDoMFuncTion()]{lastName:String[1];}", - "COMPILATION error at [1:36-49]: Can't resolve the builder for function 'ranDoMFuncTion' - stack:[Class 'test::Person' Fourth Pass, Constraint 0, new lambda, Applying ranDoMFuncTion]"); + "COMPILATION error at [1:36-49]: Can't resolve the builder for function 'ranDoMFuncTion' - stack:[Class 'test::Person' Third Pass, Constraint 0, new lambda, Applying ranDoMFuncTion]"); } @Test @@ -2410,6 +2410,78 @@ public void testClassWithBusinessTemporalMilesoning() Assert.assertEquals("Missing worksFor property in _originalMilestonedProperties for association", 1, worksForPropertyFromAssoc.size()); } + @Test + public void testClassesWithBusinessTemporalMilesoning() + { + Pair modelWithInput = + test("Class <> apps::Employee \n" + + "{ \n" + + " name: String[1]; \n" + + " firm: apps::Firm[1]; \n" + + "}\n\n" + + "Class <> apps::Firm \n" + + "{ \n" + + " name: String[1]; \n" + + "} \n" + + "Association apps::Employee_Firm \n" + + "{ \n" + + " worksFor: apps::Firm[*]; \n" + + " employs: apps::Employee[*]; \n" + + "} \n"); + PureModel model = modelWithInput.getTwo(); + Class typeEmployee = model.getClass("apps::Employee", SourceInformation.getUnknownSourceInformation()); + RichIterable> firmProperty = typeEmployee._originalMilestonedProperties().select(p -> p.getName().equals("firm")); + Assert.assertEquals("Missing firm property in _originalMilestonedProperties", 1, firmProperty.size()); + RichIterable> worksForProperty = typeEmployee._originalMilestonedProperties().select(p -> p.getName().equals("worksFor")); + Assert.assertEquals("Missing worksFor property in _originalMilestonedProperties", 1, worksForProperty.size()); + + Class typeFirm = model.getClass("apps::Firm", SourceInformation.getUnknownSourceInformation()); + RichIterable> employsProperty = typeFirm._originalMilestonedProperties().select(p -> p.getName().equals("employs")); + Assert.assertEquals("Missing employs property in _originalMilestonedProperties", 1, employsProperty.size()); + + Association association = model.getAssociation("apps::Employee_Firm", SourceInformation.getUnknownSourceInformation()); + RichIterable> originalMilestonedProperties = association._originalMilestonedProperties(); + Assert.assertEquals("Expected 2 original milestoned properties, but found " + originalMilestonedProperties.size(), 2, originalMilestonedProperties.size()); + RichIterable> worksForPropertyFromAssoc = originalMilestonedProperties.select(p -> p.getName().equals("worksFor")); + Assert.assertEquals("Missing worksFor property in _originalMilestonedProperties for association", 1, worksForPropertyFromAssoc.size()); + RichIterable> employsPropertyFromAssoc = originalMilestonedProperties.select(p -> p.getName().equals("employs")); + Assert.assertEquals("Missing employs property in _originalMilestonedProperties for association", 1, employsPropertyFromAssoc.size()); + } + + @Test + public void testClassesWithBusinessTemporalMilesoningWithDuplicatePropertyName() + { + Pair modelWithInput = + test("Class <> apps::Employee \n" + + "{ \n" + + " name: String[1]; \n" + + " firm: apps::Firm[1]; \n" + + "}\n\n" + + "Class <> apps::Firm \n" + + "{ \n" + + " name: String[1]; \n" + + " employs: apps::Employee[1]; \n" + + "} \n" + + "Association apps::Employee_Firm \n" + + "{ \n" + + " worksFor: apps::Firm[*]; \n" + + " employs: apps::Employee[*]; \n" + + "} \n"); + PureModel model = modelWithInput.getTwo(); + Class type = model.getClass("apps::Employee", SourceInformation.getUnknownSourceInformation()); + RichIterable> firmProperty = type._originalMilestonedProperties().select(p -> p.getName().equals("firm")); + Assert.assertEquals("Missing firm property in _originalMilestonedProperties", 1, firmProperty.size()); + RichIterable> worksForProperty = type._originalMilestonedProperties().select(p -> p.getName().equals("worksFor")); + Assert.assertEquals("Missing worksFor property in _originalMilestonedProperties", 1, worksForProperty.size()); + + Association association = model.getAssociation("apps::Employee_Firm", SourceInformation.getUnknownSourceInformation()); + RichIterable> worksForPropertyFromAssoc = association._originalMilestonedProperties().select(p -> p.getName().equals("worksFor")); + Assert.assertEquals("Missing worksFor property in _originalMilestonedProperties for association", 1, worksForPropertyFromAssoc.size()); + + RichIterable> employsPropertyFromAssoc = association._originalMilestonedProperties().select(p -> p.getName().equals("employs")); + Assert.assertEquals("Missing employs property in _originalMilestonedProperties for association", 1, employsPropertyFromAssoc.size()); + } + public String getMilestoningModelWithDatePropagationAndInheritance() { return "###Pure\n" + diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestMappingCompilationFromGrammar.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestMappingCompilationFromGrammar.java index be839c06558..684c2790f36 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestMappingCompilationFromGrammar.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/fromGrammar/TestMappingCompilationFromGrammar.java @@ -65,7 +65,7 @@ public void testCycleMappingInclude() " prop1: $src.prop1\n" + " }\n" + ")\n" + - "\n", "COMPILATION error at [15:1-21:1]: Cycle detected in mapping include hierarchy: test::M1 -> test::M1"); + "\n", "COMPILATION error: Detected a circular dependency in element prerequisites graph in the following metamodel: class org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.\nCycle: test::M1 -> test::M1"); test(models + "###Mapping\n" + "Mapping test::M1 (\n" + @@ -83,7 +83,7 @@ public void testCycleMappingInclude() " prop1: $src.prop1\n" + " }\n" + ")\n" + - "\n", "COMPILATION error at [15:1-21:1]: Cycle detected in mapping include hierarchy: test::M1 -> test::M2 -> test::M1"); + "\n", "COMPILATION error: Detected a circular dependency in element prerequisites graph in the following metamodel: class org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping"); test(models + "###Mapping\n" + "import test::*;\n" + @@ -110,8 +110,7 @@ public void testCycleMappingInclude() " prop1: $src.prop1\n" + " }\n" + ")\n" + - "\n", "COMPILATION error at [16:1-22:1]: Cycle detected in mapping include hierarchy: test::M1 -> " + - "test::M2 -> test::M3 -> test::M1"); + "\n", "COMPILATION error: Detected a circular dependency in element prerequisites graph in the following metamodel: class org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping"); } @Test @@ -1615,11 +1614,7 @@ public void testCrossStoreMappingWithMilestoning() @Test public void testOperationWithSubtype() - - { - - String model = "###Pure\n" + "Class example::Person\n" + "{\n" + @@ -1911,8 +1906,6 @@ public void testOperationWithSubtype() " }\n" + "\n" + ")\n", "COMPILATION error at [56:50-64]: Error in class mapping 'example::UnionOnSubTypeinclude' for property 'employees' - Type error: 'example::_S_Person' is not in the class hierarchy of 'example::_S_Cat'"); - - } @Test diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestDependencyManagement.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/TestDependencyManagement.java similarity index 59% rename from legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestDependencyManagement.java rename to legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/TestDependencyManagement.java index 42918f3e0ef..d11ae566cd5 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestDependencyManagement.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/test/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/TestDependencyManagement.java @@ -12,15 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -package org.finos.legend.engine.language.pure.compiler.test; +package org.finos.legend.engine.language.pure.compiler.toPureGraph; import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.list.FixedSizeList; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.set.FixedSizeSet; import org.eclipse.collections.api.set.MutableSet; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.DependencyManagement; +import org.eclipse.collections.api.tuple.Pair; +import org.eclipse.collections.impl.multimap.list.FastListMultimap; +import org.eclipse.collections.impl.tuple.Tuples; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement; @@ -41,6 +45,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; public class TestDependencyManagement { @@ -58,7 +63,7 @@ public class TestDependencyManagement private final java.lang.Class BINDING_CLASS = Binding.class; @Test - public void testDependencyManagementConstructor() + public void testProcessDependencyGraph() { MutableMap, Collection>> dependencyGraph = Maps.mutable.empty(); dependencyGraph.put(SECTION_INDEX_CLASS, Lists.fixedSize.empty()); @@ -70,7 +75,8 @@ public void testDependencyManagementConstructor() dependencyGraph.put(PACKAGEABLE_RUNTIME_CLASS, Lists.fixedSize.with(MAPPING_CLASS, PACKAGEABLE_CONNECTION_CLASS)); dependencyGraph.put(FUNCTION_CLASS, Lists.fixedSize.with(DATA_ELEMENT_CLASS, CLASS_CLASS, ASSOCIATION_CLASS, MAPPING_CLASS, BINDING_CLASS)); - DependencyManagement dependencyManagement = new DependencyManagement(dependencyGraph); + DependencyManagement dependencyManagement = new DependencyManagement(); + dependencyManagement.processDependencyGraph(dependencyGraph); dependencyGraph.put(MEASURE_CLASS, Lists.fixedSize.empty()); dependencyGraph.put(BINDING_CLASS, Lists.fixedSize.empty()); @@ -93,7 +99,8 @@ public void testDetectCircularDependency() dependencyGraph.put(PACKAGEABLE_RUNTIME_CLASS, Lists.fixedSize.with(MAPPING_CLASS, PACKAGEABLE_CONNECTION_CLASS)); dependencyGraph.put(FUNCTION_CLASS, Lists.fixedSize.with(DATA_ELEMENT_CLASS, CLASS_CLASS, ASSOCIATION_CLASS, MAPPING_CLASS, BINDING_CLASS)); - DependencyManagement dependencyManagement = new DependencyManagement(dependencyGraph); + DependencyManagement dependencyManagement = new DependencyManagement(); + dependencyManagement.processDependencyGraph(dependencyGraph); try { dependencyManagement.detectCircularDependency(); @@ -118,7 +125,8 @@ public void testAcyclicDependencyGraph() dependencyGraph.put(PACKAGEABLE_RUNTIME_CLASS, Lists.fixedSize.with(MAPPING_CLASS, PACKAGEABLE_CONNECTION_CLASS)); dependencyGraph.put(FUNCTION_CLASS, Lists.fixedSize.with(DATA_ELEMENT_CLASS, CLASS_CLASS, ASSOCIATION_CLASS, MAPPING_CLASS, BINDING_CLASS)); - DependencyManagement dependencyManagement = new DependencyManagement(dependencyGraph); + DependencyManagement dependencyManagement = new DependencyManagement(); + dependencyManagement.processDependencyGraph(dependencyGraph); dependencyManagement.detectCircularDependency(); MutableMap, Set>> expectedDependencyToDependents = Maps.mutable.empty(); @@ -169,7 +177,8 @@ public void testGetDisjointDependencyGraphs() dependencyGraph.put(PACKAGEABLE_RUNTIME_CLASS, Lists.fixedSize.with(MAPPING_CLASS, PACKAGEABLE_CONNECTION_CLASS)); dependencyGraph.put(FUNCTION_CLASS, Lists.fixedSize.with(DATA_ELEMENT_CLASS, CLASS_CLASS, ASSOCIATION_CLASS, MAPPING_CLASS, BINDING_CLASS)); - DependencyManagement dependencyManagement = new DependencyManagement(dependencyGraph); + DependencyManagement dependencyManagement = new DependencyManagement(); + dependencyManagement.processDependencyGraph(dependencyGraph); dependencyManagement.detectCircularDependency(); MutableSet>> expectedDisjointDependencyGraphs = Sets.mutable.empty(); @@ -181,4 +190,127 @@ public void testGetDisjointDependencyGraphs() expectedDisjointDependencyGraphs.add(disjointDependencyGraph3); Assert.assertEquals(expectedDisjointDependencyGraphs, dependencyManagement.getDisjointDependencyGraphs()); } + + @Test + public void testTopologicallySortElements() + { + DependencyManagement dependencyManagement = new DependencyManagement(); + Mapping m1 = new Mapping(); + m1._package = "test"; + m1.name = "M1"; + Mapping m2 = new Mapping(); + m2._package = "test"; + m2.name = "M2"; + Mapping m3 = new Mapping(); + m3._package = "test"; + m3.name = "M3"; + Mapping m4 = new Mapping(); + m4._package = "test"; + m4.name = "M4"; + Mapping m5 = new Mapping(); + m5._package = "test"; + m5.name = "M5"; + Mapping m6 = new Mapping(); + m6._package = "test"; + m6.name = "M6"; + Mapping m7 = new Mapping(); + m7._package = "test"; + m7.name = "M7"; + FixedSizeList testMappings = Lists.fixedSize.with(m1, m2, m3, m4, m5, m6, m7); + + DependencyManagement.PackageableElementsByDependencyLevel packageableElementsByDependencyLevel = dependencyManagement.new PackageableElementsByDependencyLevel(testMappings.stream() + .map(m -> Tuples.pair(m, m.getPath())) + .collect(Collectors.toList())); + FastListMultimap, DependencyManagement.PackageableElementsByDependencyLevel> classToElements = FastListMultimap.newMultimap(Tuples.pair(Mapping.class, packageableElementsByDependencyLevel)); + + MutableMap> mappingPrerequisiteGraphs = Maps.mutable.empty(); + mappingPrerequisiteGraphs.put(m2.getPath(), Sets.fixedSize.with(m1.getPath())); + mappingPrerequisiteGraphs.put(m3.getPath(), Sets.fixedSize.with(m1.getPath())); + mappingPrerequisiteGraphs.put(m4.getPath(), Sets.fixedSize.with(m3.getPath())); + mappingPrerequisiteGraphs.put(m5.getPath(), Sets.fixedSize.with(m3.getPath())); + mappingPrerequisiteGraphs.put(m6.getPath(), Sets.fixedSize.with(m4.getPath())); + mappingPrerequisiteGraphs.put(m7.getPath(), Sets.fixedSize.with(m4.getPath())); + MutableMap, MutableMap>> elementPrerequisitesByClass = Maps.mutable.with(Mapping.class, mappingPrerequisiteGraphs); + + FastListMultimap, DependencyManagement.PackageableElementsByDependencyLevel> classToElementsSortedByDependencyLevel = dependencyManagement.topologicallySortElements(classToElements, elementPrerequisitesByClass); + MutableList allMappingsByDependencyLevel = classToElementsSortedByDependencyLevel.get(Mapping.class); + DependencyManagement.PackageableElementsByDependencyLevel mappingsInFirstLevel = allMappingsByDependencyLevel.get(0); + FixedSizeList> independentElementAndPathPairsInFirstLevel = mappingsInFirstLevel.getIndependentElementAndPathPairs(); + Assert.assertEquals(1, independentElementAndPathPairsInFirstLevel.size()); + Assert.assertEquals(m1.getPath(), independentElementAndPathPairsInFirstLevel.get(0).getTwo()); + + DependencyManagement.PackageableElementsByDependencyLevel mappingsInSecondLevel = allMappingsByDependencyLevel.get(1); + FixedSizeList> independentElementAndPathPairsInSecondLevel = mappingsInSecondLevel.getIndependentElementAndPathPairs(); + FixedSizeSet elementPathsInSecondLevel = Sets.fixedSize.with(independentElementAndPathPairsInSecondLevel.get(0).getTwo(), independentElementAndPathPairsInSecondLevel.get(1).getTwo()); + Assert.assertEquals(2, elementPathsInSecondLevel.size()); + Assert.assertTrue(elementPathsInSecondLevel.contains(m2.getPath())); + Assert.assertTrue(elementPathsInSecondLevel.contains(m3.getPath())); + + DependencyManagement.PackageableElementsByDependencyLevel mappingsInThirdLevel = allMappingsByDependencyLevel.get(2); + FixedSizeList> independentElementAndPathPairsInThirdLevel = mappingsInThirdLevel.getIndependentElementAndPathPairs(); + FixedSizeSet elementPathsInThirdLevel = Sets.fixedSize.with(independentElementAndPathPairsInThirdLevel.get(0).getTwo(), independentElementAndPathPairsInThirdLevel.get(1).getTwo()); + Assert.assertEquals(2, elementPathsInThirdLevel.size()); + Assert.assertTrue(elementPathsInThirdLevel.contains(m4.getPath())); + Assert.assertTrue(elementPathsInThirdLevel.contains(m5.getPath())); + + DependencyManagement.PackageableElementsByDependencyLevel mappingsInFourthLevel = allMappingsByDependencyLevel.get(3); + FixedSizeList> independentElementAndPathPairsInFourthLevel = mappingsInFourthLevel.getIndependentElementAndPathPairs(); + FixedSizeSet elementPathsInFourthLevel = Sets.fixedSize.with(independentElementAndPathPairsInFourthLevel.get(0).getTwo(), independentElementAndPathPairsInFourthLevel.get(1).getTwo()); + Assert.assertEquals(2, elementPathsInFourthLevel.size()); + Assert.assertTrue(elementPathsInFourthLevel.contains(m6.getPath())); + Assert.assertTrue(elementPathsInFourthLevel.contains(m7.getPath())); + } + + @Test + public void testCircularDependencyInElements() + { + DependencyManagement dependencyManagement = new DependencyManagement(); + Mapping m1 = new Mapping(); + m1._package = "test"; + m1.name = "M1"; + Mapping m2 = new Mapping(); + m2._package = "test"; + m2.name = "M2"; + Mapping m3 = new Mapping(); + m3._package = "test"; + m3.name = "M3"; + Mapping m4 = new Mapping(); + m4._package = "test"; + m4.name = "M4"; + Mapping m5 = new Mapping(); + m5._package = "test"; + m5.name = "M5"; + Mapping m6 = new Mapping(); + m6._package = "test"; + m6.name = "M6"; + Mapping m7 = new Mapping(); + m7._package = "test"; + m7.name = "M7"; + FixedSizeList testMappings = Lists.fixedSize.with(m1, m2, m3, m4, m5, m6, m7); + + DependencyManagement.PackageableElementsByDependencyLevel packageableElementsByDependencyLevel = dependencyManagement.new PackageableElementsByDependencyLevel(testMappings.stream() + .map(m -> Tuples.pair(m, m.getPath())) + .collect(Collectors.toList())); + FastListMultimap, DependencyManagement.PackageableElementsByDependencyLevel> classToElements = FastListMultimap.newMultimap(Tuples.pair(Mapping.class, packageableElementsByDependencyLevel)); + + MutableMap> mappingPrerequisiteGraphs = Maps.mutable.empty(); + mappingPrerequisiteGraphs.put(m2.getPath(), Sets.fixedSize.with(m1.getPath())); + mappingPrerequisiteGraphs.put(m3.getPath(), Sets.fixedSize.with(m1.getPath(), m7.getPath())); + mappingPrerequisiteGraphs.put(m4.getPath(), Sets.fixedSize.with(m3.getPath())); + mappingPrerequisiteGraphs.put(m5.getPath(), Sets.fixedSize.with(m3.getPath())); + mappingPrerequisiteGraphs.put(m6.getPath(), Sets.fixedSize.with(m4.getPath())); + mappingPrerequisiteGraphs.put(m7.getPath(), Sets.fixedSize.with(m4.getPath())); + MutableMap, MutableMap>> elementPrerequisitesByClass = Maps.mutable.with(Mapping.class, mappingPrerequisiteGraphs); + + String expectedErrorMessage = "Detected a circular dependency in element prerequisites graph in the following metamodel: class org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.\nCycle: test::M7 -> test::M4 -> test::M3 -> test::M7"; + try + { + dependencyManagement.topologicallySortElements(classToElements, elementPrerequisitesByClass); + Assert.fail("Expected compilation error with message: " + expectedErrorMessage + "; but no error occurred"); + } + catch (EngineException e) + { + Assert.assertEquals(expectedErrorMessage, e.getMessage()); + } + } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar-http-api/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar-http-api/pom.xml index 2546f40bbcf..47f8a08f60c 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-grammar-http-api diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/pom.xml index 2e37a4f1f2c..69bac2adb5a 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-grammar @@ -185,6 +185,11 @@ hamcrest-core test + + commons-io + commons-io + test + - \ No newline at end of file + diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java index 22617a5098e..0eaec46331f 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java @@ -88,7 +88,7 @@ public Lambda parseLambda(String code, PureGrammarParserContext parserContext, S { ParseTreeWalkerSourceInformation lambdaWalkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(sourceId, lineOffset, columnOffset).withReturnSourceInfo(returnSourceInfo).build(); String prefix = "function go():Any[*]{"; - String fullCode = prefix + code + "}"; + String fullCode = prefix + code + "\n}"; ParseTreeWalkerSourceInformation walkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(lambdaWalkerSourceInformation) // NOTE: as we prepend the lambda with this prefix, we need to subtract this prefix length from the column offset .withColumnOffset(lambdaWalkerSourceInformation.getColumnOffset() - prefix.length()).build(); diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/DEPRECATED_PureGrammarComposerCore.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/DEPRECATED_PureGrammarComposerCore.java index fa02df963c8..57564449537 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/DEPRECATED_PureGrammarComposerCore.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/to/DEPRECATED_PureGrammarComposerCore.java @@ -16,8 +16,10 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.collections.api.block.function.Function2; +import org.eclipse.collections.api.set.ImmutableSet; import org.eclipse.collections.impl.block.factory.Functions; import org.eclipse.collections.impl.factory.Lists; +import org.eclipse.collections.impl.factory.Sets; import org.eclipse.collections.impl.list.mutable.ListAdapter; import org.eclipse.collections.impl.tuple.Tuples; import org.eclipse.collections.impl.utility.LazyIterate; @@ -295,6 +297,7 @@ public String returnChar() return this.isRenderingHTML() ? "
\n" : "\n"; } + private static final ImmutableSet CORE_FUNCTIONS_WITH_PREFIX_RENDERING = Sets.immutable.of("if", "over"); // ----------------------------------------------- GENERAL ----------------------------------------------- @@ -820,7 +823,7 @@ else if (parameters.size() == 1) + (toCreateNewLine ? this.returnChar() + DEPRECATED_PureGrammarComposerCore.computeIndentationString(this, getTabSize(1)) : " ") + possiblyAddParenthesis(function, parameters.get(1), this); } - else if ("if".equals(function)) + else if (function != null && CORE_FUNCTIONS_WITH_PREFIX_RENDERING.contains(function)) { return HelperValueSpecificationGrammarComposer.renderFunctionName(function, this) + "(" + (this.isRenderingPretty() ? this.returnChar() + DEPRECATED_PureGrammarComposerCore.computeIndentationString(this, getTabSize(1)) : "") + diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/GrammarParseTestUtils.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/GrammarParseTestUtils.java new file mode 100644 index 00000000000..60636a2bb94 --- /dev/null +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/GrammarParseTestUtils.java @@ -0,0 +1,64 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.language.pure.grammar.test; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.eclipse.collections.impl.list.mutable.FastList; +import org.eclipse.collections.impl.utility.internal.IterableIterate; +import org.finos.legend.engine.language.pure.grammar.from.PureGrammarParser; +import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; + +import java.io.IOException; +import java.util.Objects; + +public class GrammarParseTestUtils +{ + public static PureModelContextData loadPureModelContextFromResource(String resource, Class clazz) + { + return loadPureModelContextFromResource(resource, null, clazz); + } + + public static PureModelContextData loadPureModelContextFromResource(String resource, String extraCode, Class clazz) + { + return loadPureModelContextFromResources(FastList.newListWith(resource), extraCode, clazz); + } + + public static PureModelContextData loadPureModelContextFromResources(Class clazz, String... resources) + { + return loadPureModelContextFromResources(FastList.newListWith(resources), null, clazz); + } + + public static PureModelContextData loadPureModelContextFromResources(Iterable resources, String extraCode, Class clazz) + { + String resourceCode = StringUtils.join(IterableIterate.collect(resources, r -> getResource(r, clazz)), "\n"); + String code = extraCode != null ? resourceCode + "\n" + extraCode : resourceCode; + + return PureModelContextData.newBuilder().withPureModelContextData(PureGrammarParser.newInstance().parseModel(code)).build(); + } + + + public static String getResource(String resource, Class clazz) + { + try + { + return IOUtils.toString(Objects.requireNonNull(clazz.getClassLoader().getResourceAsStream(resource))); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + } +} \ No newline at end of file diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java index 027ff3041c3..a702604bccc 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java @@ -19,6 +19,7 @@ import org.finos.legend.engine.language.pure.grammar.to.DEPRECATED_PureGrammarComposerCore; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda; import org.finos.legend.engine.shared.core.ObjectMapperFactory; +import org.finos.legend.engine.shared.core.api.grammar.RenderStyle; import org.junit.Assert; import org.junit.Test; @@ -435,12 +436,33 @@ public void testRenderingFunctionExpressionWithSinglePrimitiveArgument() testLambda("|%9999-12-30T19:00:00.0000->someDateFn()", "|someDateFn(%9999-12-30T19:00:00.0000)"); } + @Test + public void testLambdaEndingOnComment() + { + testLambda("|1 + 1// comment here", "|1 + 1"); + } + static void testLambda(String text) { - testLambda(text, text); + testLambda(text, text, RenderStyle.STANDARD); } static void testLambda(String text, String formattedText) + { + testLambda(text, formattedText, RenderStyle.STANDARD); + } + + static void testLambdaPretty(String text) + { + testLambda(text, text, RenderStyle.PRETTY); + } + + static void testLambdaPretty(String text, String formattedText) + { + testLambda(text, formattedText, RenderStyle.PRETTY); + } + + static void testLambda(String text, String formattedText, RenderStyle renderStyle) { Lambda postJSON_lambda; try @@ -453,6 +475,6 @@ static void testLambda(String text, String formattedText) { throw new RuntimeException(e); } - Assert.assertEquals(formattedText, postJSON_lambda.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().build())); + Assert.assertEquals(formattedText, postJSON_lambda.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().withRenderStyle(renderStyle).build())); } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestRelation.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestRelation.java index 71ebf53b14c..e95cf2a49e0 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestRelation.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestRelation.java @@ -17,6 +17,7 @@ import org.junit.Test; import static org.finos.legend.engine.language.pure.grammar.test.roundtrip.TestLambdaRoundtrip.testLambda; +import static org.finos.legend.engine.language.pure.grammar.test.roundtrip.TestLambdaRoundtrip.testLambdaPretty; public class TestRelation { @@ -91,4 +92,36 @@ public void testCast() { testLambda("|test::Person.all()->meta::pure::functions::lang::cast(@Relation<(someCol:String, someCol:String)>)"); } + + @Test + public void testOver() + { + testLambda("|over(~a)"); + testLambda("|over(~[a, b], !c->descending())"); + testLambda("|over(~[a, b], !c->descending(), [])"); + testLambdaPretty( + "|over(\n" + + " ~a\n" + + ")" + ); + testLambdaPretty( + "|over(\n" + + " ~[\n" + + " a,\n" + + " b\n" + + " ],\n" + + " !c->descending()\n" + + ")" + ); + testLambdaPretty( + "|over(\n" + + " ~[\n" + + " a,\n" + + " b\n" + + " ],\n" + + " !c->descending(),\n" + + " []\n" + + ")" + ); + } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc-http-api/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc-http-api/pom.xml index b2f574142b0..a388ccd3feb 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-modelManager-sdlc-http-api diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc/pom.xml index aa9844c9f6e..9aea81ba2c4 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager-sdlc/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-modelManager-sdlc diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager/pom.xml index 652cd05e757..f9caa24b6f3 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-modelManager/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-modelManager diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-http-api/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-http-api/pom.xml index 26a41495576..1d08f57159b 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-protocol-http-api diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/pom.xml index a9581921553..e58a7e918bf 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-protocol-pure diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/context/PackageableElementType.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/context/PackageableElementType.java index 3be6d626f0f..e5bd1d06827 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/context/PackageableElementType.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/context/PackageableElementType.java @@ -24,6 +24,7 @@ public enum PackageableElementType FUNCTION, STORE, RUNTIME, + BINDING, MAPPING, SERVICE, PERSISTENCE, diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol/pom.xml index c3687269072..b8edec0746a 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-language-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-protocol diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/pom.xml b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/pom.xml index fe8ec2f1642..76843ef4dff 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/pom.xml +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-base - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-base/pom.xml b/legend-engine-core/legend-engine-core-base/pom.xml index c256111675a..f1a9ef368b5 100644 --- a/legend-engine-core/legend-engine-core-base/pom.xml +++ b/legend-engine-core/legend-engine-core-base/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/legend-engine-external-shared-format-runtime/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/legend-engine-external-shared-format-runtime/pom.xml index ff2e076cd8c..079e79e4eb5 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/legend-engine-external-shared-format-runtime/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/legend-engine-external-shared-format-runtime/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-external-format-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/pom.xml index b6dad7fda0e..9293b53288d 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-execution/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-external-format - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/pom.xml index a43bc78ad3b..a7439f44a92 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-external-format-language - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/BindingCompiler.java b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/BindingCompiler.java index 27a089a99bb..f0bdb9d4a2b 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/BindingCompiler.java +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/BindingCompiler.java @@ -39,7 +39,6 @@ public class BindingCompiler { private final Map> externalFormatExtensions; private final ConcurrentHashMap bindingIndex = new ConcurrentHashMap<>(); - private final ConcurrentHashMap srcSchemaIndex = new ConcurrentHashMap<>(); public BindingCompiler(Map> externalFormatExtensions) { @@ -48,7 +47,7 @@ public BindingCompiler(Map> externalFormatExt public Processor getProcessor() { - return Processor.newProcessor(Binding.class, Collections.singletonList(ExternalFormatSchemaSet.class), this::firstPass, this::secondPass, this::thirdPass, this::fourthPass); + return Processor.newProcessor(Binding.class, Collections.singletonList(ExternalFormatSchemaSet.class), this::firstPass, this::secondPass, this::thirdPass); } public Root_meta_external_format_shared_binding_Binding getCompiledBinding(String fullPath) @@ -111,15 +110,7 @@ private void thirdPass(Binding srcBinding, CompileContext context) { throw new EngineException("Content type and SchemaSet format do not match", srcBinding.sourceInformation, EngineErrorType.COMPILATION); } - } - - // Fourth pass - ensure correlation using the extension - private void fourthPass(Binding srcBinding, CompileContext context) - { - String path = context.pureModel.buildPackageString(srcBinding._package, srcBinding.name); - Root_meta_external_format_shared_binding_Binding compiled = bindingIndex.get(path); - ExternalFormatExtension schemaExtension = getExtension(compiled, srcBinding); Root_meta_external_format_shared_binding_validation_BindingDetail bindingDetail = schemaExtension.bindDetails(compiled, context); if (bindingDetail instanceof Root_meta_external_format_shared_binding_validation_FailedBindingDetail) { diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-core/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-core/pom.xml index 703f4351f6f..279234515a9 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-core/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-core/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-external-format-language - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-example/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-example/pom.xml index 9dbe5434a2e..556d24c8140 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-example/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-example/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-external-format-language - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-generation/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-generation/pom.xml index 6dd41f6026d..f90efe59094 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-generation/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-external-format-language - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-grammar/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-grammar/pom.xml index ad089b67229..43db8f0c388 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-grammar/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-external-format-language - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-http-api/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-http-api/pom.xml index a987aa0110d..39acfbc2cd8 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/legend-engine-external-format-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-external-format-language - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/pom.xml b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/pom.xml index 2b33802ad1a..40f6084c6a1 100644 --- a/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/legend-engine-external-format-language/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-external-format - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-external-format/pom.xml b/legend-engine-core/legend-engine-core-external-format/pom.xml index 85bccb0bf63..0470f1b254c 100644 --- a/legend-engine-core/legend-engine-core-external-format/pom.xml +++ b/legend-engine-core/legend-engine-core-external-format/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-identity/legend-engine-identity-core/pom.xml b/legend-engine-core/legend-engine-core-identity/legend-engine-identity-core/pom.xml index c5bcfea5bd0..7f7cbcdd45f 100644 --- a/legend-engine-core/legend-engine-core-identity/legend-engine-identity-core/pom.xml +++ b/legend-engine-core/legend-engine-core-identity/legend-engine-identity-core/pom.xml @@ -3,7 +3,7 @@ legend-engine-core-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-identity/pom.xml b/legend-engine-core/legend-engine-core-identity/pom.xml index 161a795ff7e..8955fc03df0 100644 --- a/legend-engine-core/legend-engine-core-identity/pom.xml +++ b/legend-engine-core/legend-engine-core-identity/pom.xml @@ -3,7 +3,7 @@ legend-engine-core org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/pom.xml index 1504833328e..2366b942925 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-core-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-code-compiled-core @@ -205,7 +205,6 @@ legend-engine-pure-runtime-java-extension-compiled-functions-unclassified ${project.version} - @@ -251,23 +250,11 @@ org.finos.legend.pure legend-pure-runtime-java-engine-compiled - - - - - - - - org.finos.legend.engine legend-engine-pure-platform-java - - org.finos.legend.engine - legend-engine-pure-functions-standard-pure - org.finos.legend.engine legend-engine-pure-platform-dsl-diagram-java @@ -307,16 +294,7 @@ org.finos.legend.engine legend-engine-pure-runtime-java-extension-compiled-functions-json - - - - - - - - - org.finos.legend.pure legend-pure-runtime-java-extension-compiled-store-relational @@ -450,12 +428,11 @@ - - + + - @@ -465,9 +442,4 @@
- - - - - diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/legend/tools/devUtils.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/legend/tools/devUtils.pure index 76ca1bf7f62..aab50f8fd70 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/legend/tools/devUtils.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/legend/tools/devUtils.pure @@ -45,3 +45,10 @@ function meta::legend::executePlanAsJSON(plan:String[1], vars: Pair let func = $fStr->pathToElement()->cast(@Function<{String[1], Pair[*]->String[1]}>); $func->eval($plan, $vars); } + +function meta::legend::compileLegendPMCD(pmcdJSON : String[1]):PackageableElement[*] +{ + let fStr = 'meta::legend::compilePMCD_String_1__PackageableElement_MANY_'; + let func = $fStr->pathToElement()->cast(@Function<{String[1]->PackageableElement[*]}>); + $func->eval($pmcdJSON); +} \ No newline at end of file diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/metaExtension.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/metaExtension.pure index 8d124709cca..8c7752643b6 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/metaExtension.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/metaExtension.pure @@ -137,7 +137,7 @@ function {doc.doc = 'Recursively get all explicitly defined generalizations.'} meta::pure::functions::meta::hierarchicalAllGeneralizations(type : Type[1]) : Class[*] { let oneLevel = $type->validGeneralizations(); - $oneLevel->concatenate($oneLevel->map(c | $c->validGeneralizations()))->removeDuplicates(); + $oneLevel->concatenate($oneLevel->map(c | $c->hierarchicalAllGeneralizations()))->removeDuplicates(); } function {doc.doc = 'Get all inherited properties on the provided class'} @@ -328,7 +328,7 @@ function meta::pure::functions::meta::findPackagableElement(fe : ValueSpecificat ->findPackagableElement(), p : PackageableElement[1] | $p ]);, - i:ClassConstraintValueSpecificationContext[1] | $i.class, + i:ClassConstraintValueSpecificationContext[1] | $i.type->cast(@PackageableElement), i:InstanceValueSpecificationContext[1] | $i.instanceValue->meta::pure::functions::meta::findPackagableElement(), p:ParameterValueSpecificationContext[1] | $p.functionExpression->meta::pure::functions::meta::findPackagableElement(), k:KeyValueValueSpecificationContext[1] | $k.functionExpression->meta::pure::functions::meta::findPackagableElement() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/testExtension.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/testExtension.pure index e01222cced1..89708d1a1df 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/testExtension.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/testExtension.pure @@ -183,7 +183,7 @@ function <> meta::pure::functions::test::testedBy(vs:ValueSpecif iv:InstanceValueSpecificationContext[1] | $iv.instanceValue->testedBy($soFar, $extensions), pv:ParameterValueSpecificationContext[1] | $pv.functionExpression->testedBy($soFar, $extensions), kv:KeyValueValueSpecificationContext[1] | $kv.functionExpression->testedBy($soFar, $extensions), - cc:ClassConstraintValueSpecificationContext[1] | $cc.class->testedBy($soFar, $extensions), + cc:ClassConstraintValueSpecificationContext[1] | $cc.type->testedBy($soFar, $extensions), an:Any[*] | $soFar ]); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtension.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtension.pure index 61856509c72..cdaa1245c65 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtension.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtension.pure @@ -355,3 +355,9 @@ function <> meta::pure::functions::meta::tests::testTypeNameAndPath() assertEquals( meta::pure::functions::tests::model::GeographicEntityType.CITY->typePath(),'meta::pure::functions::tests::model::GeographicEntityType'); } + +function <> meta::pure::functions::meta::tests::testAllGeneralizations(): Boolean[1] +{ + assertEquals(['Parent'], meta::pure::functions::meta::validGeneralizations(meta::pure::functions::meta::tests::packageA::Child)->map(t | $t.name)); + assertEquals(['Parent', 'GrandParent', 'GreatGrandParent'], meta::pure::functions::meta::hierarchicalAllGeneralizations(meta::pure::functions::meta::tests::packageA::Child)->map(t | $t.name)); +} \ No newline at end of file diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtention_funcs.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtention_funcs.pure index 0e42b3068ee..792f83c6cca 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtention_funcs.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/metaExtention_funcs.pure @@ -28,6 +28,26 @@ Class meta::pure::functions::meta::tests::packageA::ClassB } +Class meta::pure::functions::meta::tests::packageA::Child extends meta::pure::functions::meta::tests::packageA::Parent +{ + +} + +Class meta::pure::functions::meta::tests::packageA::Parent extends meta::pure::functions::meta::tests::packageA::GrandParent +{ + +} + +Class meta::pure::functions::meta::tests::packageA::GrandParent extends meta::pure::functions::meta::tests::packageA::GreatGrandParent +{ + +} + +Class meta::pure::functions::meta::tests::packageA::GreatGrandParent +{ + +} + function <> meta::pure::functions::meta::tests::packageA::myFunc():Boolean[1] { true diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/scanProperties.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/scanProperties.pure index dc5c8e1cda6..d23c25a8705 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/scanProperties.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/scanProperties.pure @@ -479,6 +479,7 @@ function <> meta::pure::lineage::scanProperties::processFunction let fromParams = makeScanPropertiesState(emptyPath(), $paramPaths.result, $visitedFunctions); $fn->match([ {f0:Function[0] | $fromParams}, + {p:Path[1]| makeScanPropertiesState(emptyPath(), $p->scanPath(emptyPath(), $processed, $vars, $config, $visitedFunctions, $debug), $visitedFunctions)}, {f:Function[1] | if($f.name->isEmpty() || !isPackageOk($f), @@ -718,7 +719,8 @@ function meta::pure::lineage::scanProperties::printPropertyNodeLists(properyList function <> meta::pure::lineage::scanProperties::propertyTree::recurseBuildTree(list:List[*]):PropertyPathTree[*] { let m = $list->filter(l|!$l.values->isEmpty())->groupBy(l|$l.values->at(0)); - $m->keys()->map( + + $m->keys()->sortBy(v | $v.property.name->toOne())->map( k|^PropertyPathTree(display = $k.property->match([p:Property[1]|'',q:QualifiedProperty[1]|'(Q)'])+$k.property.name->toOne(), value = $k, children = $m->get($k).values->map(l|^$l(values=$l.values->slice(1, $l.values->size())))->recurseBuildTree(), diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/routing.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/routing.pure index e756af5bbc9..5ad8c440348 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/routing.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/routing.pure @@ -365,7 +365,11 @@ function meta::pure::router::store::routing::specializedFunctionExpressionRoute $r->reactivate($inScopeVars);, i:InstanceValue[1] |$i.values])); let fromMapping = $resolvedParameters->at(0)->cast(@Mapping); - let fromRuntime = $resolvedParameters->at(1)->cast(@Runtime); + let fromRuntime = $resolvedParameters->at(1) + ->match([ + r:Runtime[1]| $r, + fe: FunctionExpression[1] | $fe->meta::pure::router::preeval::preval($inScopeVars, $extensions, $debug)->reactivate($inScopeVars) + ])->toOne()->cast(@Runtime); let fromExecutionContext = if($resolvedParameters->size() == 3, | $resolvedParameters->at(2)->cast(@meta::pure::runtime::ExecutionContext), | $executionContext); let currentRoutingStrategy = $state.routingStrategy; diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure index e8fcae27ff1..c5ae8242572 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure @@ -113,6 +113,7 @@ function meta::pure::metamodel::serialization::grammar::printInstanceValue(i:Ins f:FunctionExpression[1] | $f->printPropertyOrFunctionExpression($configuration, $space), x:InstanceValue[1] | $x->printInstanceValue($configuration, $space), z:KeyExpression[*] | $z->map(f|$f.key.values->toOne()->toString())->joinStrings(','), + v:VariableExpression[1] | $v->printValueSpecification($configuration, $space), r:Runtime[1]|'^meta::core::runtime::Runtime('+ 'connectionStores='+$r.connectionStores->map(s|'^meta::core::runtime::ConnectionStore(connection='+$s.connection->printConnection($configuration)+', element='+$s.element->match([x:String[1]|$x,x:Store[1]|$x->elementToPath()])+')')->makeString(',')+ ')', diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreCompiledStateIntegrity.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreCompiledStateIntegrity.java index 60fbab53251..436959ac22e 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreCompiledStateIntegrity.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreCompiledStateIntegrity.java @@ -14,10 +14,6 @@ package org.finos.legend.engine.pure.code.core; -import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProviderHelper; -import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.MutableRepositoryCodeStorage; -import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.classpath.ClassLoaderCodeStorage; -import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.composite.CompositeCodeStorage; import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; import org.junit.BeforeClass; import org.junit.Ignore; @@ -28,8 +24,7 @@ public class TestCoreCompiledStateIntegrity extends AbstractCompiledStateIntegri @BeforeClass public static void initialize() { - MutableRepositoryCodeStorage codeStorage = new CompositeCodeStorage(new ClassLoaderCodeStorage(CodeRepositoryProviderHelper.findCodeRepositories())); - initialize(codeStorage); + initialize("core"); } @Test diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-core-extension/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-core-extension/pom.xml index e2bce0f64b6..6dc38444804 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-core-extension/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-core-extension/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-core-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-code-core-extension diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/pom.xml index 830ea376612..3c65fdd26c7 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/json/TestFunctionsJsonCompiledStateStrategy.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/json/TestFunctionsJsonCompiledStateIntegrity.java similarity index 90% rename from legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/json/TestFunctionsJsonCompiledStateStrategy.java rename to legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/json/TestFunctionsJsonCompiledStateIntegrity.java index 2cc43504b61..feae4d96ebc 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/json/TestFunctionsJsonCompiledStateStrategy.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-functions-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/json/TestFunctionsJsonCompiledStateIntegrity.java @@ -17,7 +17,7 @@ import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; import org.junit.BeforeClass; -public class TestFunctionsJsonCompiledStateStrategy extends AbstractCompiledStateIntegrityTest +public class TestFunctionsJsonCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest { @BeforeClass public static void initialize() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/pom.xml index a3cb3143dfb..b176416eed6 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT ../pom.xml diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonNativeImplementation.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonNativeImplementation.java index c4861fa0469..7a1b0892ee2 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonNativeImplementation.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonNativeImplementation.java @@ -15,6 +15,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.compiled; import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty; @@ -90,11 +91,11 @@ private RichIterable findAndInvokePropertyMethod(Any pureObject, String prope } catch (NoSuchMethodException e) { - throw new PureExecutionException(si, "Error retrieving value of a property: " + propertyName + " from the class " + className + ". Property might not exist", e); + throw new PureExecutionException(si, "Error retrieving value of a property: " + propertyName + " from the class " + className + ". Property might not exist", e, Stacks.mutable.empty()); } catch (Exception e) { - throw new PureExecutionException(si, "Error serializing property: " + propertyName, e); + throw new PureExecutionException(si, "Error serializing property: " + propertyName, e, Stacks.mutable.empty()); } } }, si); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/PureMapSerializer.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/PureMapSerializer.java index 42d39b7a24e..aed1122da1e 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/PureMapSerializer.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/PureMapSerializer.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.compiled; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.runtime.java.extension.external.json.shared.JsonSerializationContext; import org.finos.legend.pure.runtime.java.extension.external.shared.conversion.Conversion; import org.eclipse.collections.api.block.procedure.Procedure2; @@ -36,7 +37,7 @@ public void value(Object key, Object value) { if (!(key instanceof String)) { - throw new PureExecutionException("Only String-key map conversions are supported, found key: " + key); + throw new PureExecutionException("Only String-key map conversions are supported, found key: " + key, Stacks.mutable.empty()); } result.put(key, toJson(value, context)); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/natives/JsonParserHelper.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/natives/JsonParserHelper.java index 5a42313aba4..6e7dfcdcedf 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/natives/JsonParserHelper.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/compiled/natives/JsonParserHelper.java @@ -15,6 +15,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.compiled.natives; import org.apache.commons.lang3.reflect.MethodUtils; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ConstraintsOverride; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.execution.ExecutionSupport; @@ -55,7 +56,7 @@ public static void multiplicityIsInRange(JSONArray array, int lowerBound, int up if (outsideLowerBound || outsideUpperBound) { - throw new PureExecutionException(si, "Expected value(s) of multiplicity " + humanReadableMultiplicity + ", found " + array.size() + " value(s)."); + throw new PureExecutionException(si, "Expected value(s) of multiplicity " + humanReadableMultiplicity + ", found " + array.size() + " value(s).", Stacks.mutable.empty()); } } @@ -75,7 +76,7 @@ public static void multiplicityIsInRange(Object object, int lowerBound, int uppe if (outsideLowerBound || outsideUpperBound) { - throw new PureExecutionException(si, "Expected value(s) of multiplicity " + humanReadableMultiplicity + ", found " + errorMsg + " value(s)."); + throw new PureExecutionException(si, "Expected value(s) of multiplicity " + humanReadableMultiplicity + ", found " + errorMsg + " value(s).", Stacks.mutable.empty()); } } @@ -127,7 +128,7 @@ else if (actualValue instanceof List) actualType = actualValue.getClass().getSimpleName(); } } - throw new PureExecutionException("Expected " + expectedPureType + ", found " + actualType); + throw new PureExecutionException("Expected " + expectedPureType + ", found " + actualType, Stacks.mutable.empty()); } } @@ -197,13 +198,13 @@ public static T fromJson(Object value, Class resultType, String fullClass enumerationFullUserPath = enumString.substring(0, dotIndex); if (!fullClassName.regionMatches(5, enumerationFullUserPath.replace("::", "_"), 0, fullClassName.length() - 5)) { - throw new PureExecutionException(si, "Expected enum of type " + fullClassName + "; got: " + enumString); + throw new PureExecutionException(si, "Expected enum of type " + fullClassName + "; got: " + enumString, Stacks.mutable.empty()); } } T result = (T) metadata.getEnum(enumerationFullUserPath, enumName); if (result == null) { - throw new PureExecutionException(si, "Unknown enum: " + fullClassName + "." + enumName); + throw new PureExecutionException(si, "Unknown enum: " + fullClassName + "." + enumName, Stacks.mutable.empty()); } return result; } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/resources/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonGen.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/resources/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonGen.java index a5e757d532d..bc800c7d3ff 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/resources/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonGen.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-compiled-functions-json/src/main/resources/org/finos/legend/pure/runtime/java/extension/external/json/compiled/JsonGen.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.list.MutableList; import org.finos.legend.pure.generated.CoreGen; import org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair; @@ -141,7 +142,7 @@ public T newUnitInstance(CoreInstance propertyType, String unitT { PackageableElement.writeUserPathForPackageableElement(builder, propertyType); } - throw new PureExecutionException(builder.toString()); + throw new PureExecutionException(builder.toString(), Stacks.mutable.empty()); } return (T) CompiledSupport.newUnitInstance(unitRetrieved, unitValue, es); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/pom.xml index 964ed41e384..a0a76ad785d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT ../pom.xml diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/Escape.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/Escape.java index 0e6434623e1..ebd68905669 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/Escape.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/Escape.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.interpreted.natives; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.runtime.java.interpreted.FunctionExecutionInterpreted; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; @@ -46,7 +47,7 @@ public Escape(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String str = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); return ValueSpecificationBootstrap.wrapValueSpecification(this.repository.newCoreInstance(JSONObject.escape(str), processorSupport.package_getByUserPath(M3Paths.String), null), ValueSpecification.isExecutable(params.get(0), processorSupport), processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJson.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJson.java index 22e13fa500d..e3f32900f6f 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJson.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJson.java @@ -19,6 +19,7 @@ import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Any; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class; @@ -72,9 +73,9 @@ public FromJson(FunctionExecutionInterpreted functionExecution, ModelRepository @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - SourceInformation si = functionExpressionToUseInStack.getSourceInformation(); + SourceInformation si = functionExpressionCallStack.peek().getSourceInformation(); Class startingClass = (Class) Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport); CoreInstance config = Instance.getValueForMetaPropertyToOneResolved(params.get(2), M3Properties.values, processorSupport); @@ -93,8 +94,8 @@ public CoreInstance execute(ListIterable params, Stack T newObject(Class clazz, Map> properties) { - CoreInstance instance = FromJson.this.repository.newEphemeralAnonymousCoreInstance(functionExpressionToUseInStack.getSourceInformation(), clazz); - properties.forEach((key, values) -> Instance.setValuesForProperty(instance, key, values.collect(value -> convertValue(key, value, processorSupport, si), Lists.mutable.empty()), processorSupport)); + CoreInstance instance = FromJson.this.repository.newEphemeralAnonymousCoreInstance(functionExpressionCallStack.peek().getSourceInformation(), clazz); + properties.forEach((key, values) -> Instance.setValuesForProperty(instance, key, values.collect(value -> convertValue(key, value, functionExpressionCallStack, processorSupport, si), Lists.mutable.empty()), processorSupport)); DeserializationUtils.replaceReverseProperties(instance, processorSupport, si); CoreInstance override = processorSupport.newAnonymousCoreInstance(si, M3Paths.ConstraintsGetterOverride); @@ -105,7 +106,7 @@ public T newObject(Class clazz, Map> } CoreInstance value = ValueSpecificationBootstrap.wrapValueSpecification(instance, true, processorSupport); - return (T) DefaultConstraintHandler.handleConstraints(clazz, value, si, functionExecution, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport); + return (T) DefaultConstraintHandler.handleConstraints(clazz, value, si, functionExecution, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport); } @Override @@ -123,18 +124,18 @@ public T newUnitInstance(CoreInstance propertyType, String unitT { PackageableElement.writeUserPathForPackageableElement(builder, propertyType); } - throw new PureExecutionException(builder.toString()); + throw new PureExecutionException(builder.toString(), functionExpressionCallStack); } ListIterable params = Lists.immutable.with( ValueSpecificationBootstrap.wrapValueSpecification(retrievedUnit, false, processorSupport), NumericUtilities.toPureNumberValueExpression(unitValue, false, repository, processorSupport)); - return (T) new NewUnit(repository).execute(params, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, context, processorSupport); + return (T) new NewUnit(repository).execute(params, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, context, processorSupport); } })); } - private CoreInstance convertValue(String key, Object value, ProcessorSupport processorSupport, SourceInformation sourceInfo) + private CoreInstance convertValue(String key, Object value, MutableStack functionExpressionCallStack, ProcessorSupport processorSupport, SourceInformation sourceInfo) { if (value instanceof String) { @@ -181,6 +182,6 @@ private CoreInstance convertValue(String key, Object value, ProcessorSupport pro { return (CoreInstance) value; } - throw new PureExecutionException(sourceInfo, "Unknown type from output of JsonDeserializer for property: " + key); + throw new PureExecutionException(sourceInfo, "Unknown type from output of JsonDeserializer for property: " + key, functionExpressionCallStack); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJsonDeprecated.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJsonDeprecated.java index 221d1b9afd5..797e3297f51 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJsonDeprecated.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/FromJsonDeprecated.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -50,7 +51,7 @@ public FromJsonDeprecated(FunctionExecutionInterpreted functionExecution, ModelR } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { // This is a temporary solution as it should not be referring to the other existing implementation which is in the model // space. It either needs its own native implementation or a function inside the platform. @@ -65,6 +66,6 @@ public CoreInstance execute(ListIterable params, Stack functionParameters = Lists.immutable.with(ValueSpecificationBootstrap.wrapValueSpecification(jsonElement, true, processorSupport), startingclass, config); - return this.functionExecution.executeLambdaFromNative(fromContractStoreJSONFunction, functionParameters, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport); + return this.functionExecution.executeLambdaFromNative(fromContractStoreJSONFunction, functionParameters, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/JsonStringsEqual.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/JsonStringsEqual.java index 5bfba7fe442..3dbe2bd11cb 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/JsonStringsEqual.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/JsonStringsEqual.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.interpreted.natives; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.runtime.java.interpreted.FunctionExecutionInterpreted; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; @@ -42,7 +43,7 @@ public JsonStringsEqual(FunctionExecutionInterpreted functionExecution, ModelRep } @Override - protected boolean executeBoolean(Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, ListIterable params, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport) throws PureExecutionException + protected boolean executeBoolean(Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, ListIterable params, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance left = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport); CoreInstance right = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport); @@ -56,7 +57,7 @@ protected boolean executeBoolean(Stack> resolve catch (ParseException e) { //ParseException implementation returns human readable error message from toString() method and getMessage() returns null - throw new PureExecutionException(functionExpressionToUseInStack.getSourceInformation(), "Failed to parse JSON string. Invalid JSON string. " + e.toString(), e); + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), "Failed to parse JSON string. Invalid JSON string. " + e.toString(), e, functionExpressionCallStack); } } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ParseJSON.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ParseJSON.java index d54f0f00ab2..e3c016913ec 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ParseJSON.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ParseJSON.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.interpreted.natives; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m4.ModelRepository; import org.finos.legend.pure.runtime.java.interpreted.FunctionExecutionInterpreted; import org.eclipse.collections.api.list.ListIterable; @@ -47,7 +48,7 @@ public ParseJSON(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String txt = PrimitiveUtilities.getStringValue(Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport)); return ValueSpecificationBootstrap.wrapValueSpecification(new JsonParser(processorSupport).toPureJson(txt), true, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ToJson.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ToJson.java index 71f2e30e96e..86289e2f683 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ToJson.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-interpreted-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/interpreted/natives/ToJson.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty; @@ -62,7 +63,7 @@ public ToJson(FunctionExecutionInterpreted functionExecution, ModelRepository mo } @Override - public CoreInstance execute(ListIterable params, final Stack> resolvedTypeParameters, final Stack> resolvedMultiplicityParameters, final VariableContext variableContext, final CoreInstance functionExpressionToUseInStack, final Profiler profiler, final InstantiationContext instantiationContext, final ExecutionSupport executionSupport, Context context, final ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, final Stack> resolvedTypeParameters, final Stack> resolvedMultiplicityParameters, final VariableContext variableContext, MutableStack functionExpressionCallStack, final Profiler profiler, final InstantiationContext instantiationContext, final ExecutionSupport executionSupport, Context context, final ProcessorSupport processorSupport) throws PureExecutionException { ListIterable pureObjects = Instance.getValueForMetaPropertyToManyResolved(params.get(0), M3Properties.values, processorSupport); if (pureObjects.getFirst() instanceof SimpleCoreInstance && !"Map".equals(pureObjects.getFirst().getClassifier().getName())) @@ -83,7 +84,7 @@ public CoreInstance execute(ListIterable params, final S ListIterable encryptionStereotypes = jsonConfig.getValueForMetaPropertyToMany("encryptionStereotypes"); ListIterable decryptionStereotypes = jsonConfig.getValueForMetaPropertyToMany("decryptionStereotypes"); - String json = JsonSerializer.toJson(pureObjects, processorSupport, new JsonSerializationContext(new JsonSerializationCache(), functionExpressionToUseInStack.getSourceInformation(), processorSupport, new Stack<>(), typeKeyName, includeType, fullyQualifiedTypePath, serializeQualifiedProperties, dateTimeFormat, serializePackageableElementName, removePropertiesWithEmptyValues, serializeMultiplicityAsNumber, encryptionKey, encryptionStereotypes, decryptionKey, decryptionStereotypes) + String json = JsonSerializer.toJson(pureObjects, processorSupport, new JsonSerializationContext(new JsonSerializationCache(), functionExpressionCallStack.peek().getSourceInformation(), processorSupport, new Stack<>(), typeKeyName, includeType, fullyQualifiedTypePath, serializeQualifiedProperties, dateTimeFormat, serializePackageableElementName, removePropertiesWithEmptyValues, serializeMultiplicityAsNumber, encryptionKey, encryptionStereotypes, decryptionKey, decryptionStereotypes) { @Override protected Object extractPrimitiveValue(Object potentiallyWrappedPrimitive) @@ -96,7 +97,7 @@ protected Object extractPrimitiveValue(Object potentiallyWrappedPrimitive) @Override protected Object getValueForProperty(CoreInstance pureObject, Property property, String className) { - CoreInstance res = ToJson.this.functionExecution.executeProperty(property, true, resolvedTypeParameters, resolvedMultiplicityParameters, getParentOrEmptyVariableContext(variableContext), profiler, Lists.immutable.with(ValueSpecificationBootstrap.wrapValueSpecification(pureObject, true, processorSupport)), functionExpressionToUseInStack, instantiationContext, executionSupport); + CoreInstance res = ToJson.this.functionExecution.executeProperty(property, true, resolvedTypeParameters, resolvedMultiplicityParameters, getParentOrEmptyVariableContext(variableContext), profiler, Lists.immutable.with(ValueSpecificationBootstrap.wrapValueSpecification(pureObject, true, processorSupport)), functionExpressionCallStack, instantiationContext, executionSupport); if (res instanceof InstanceValue) { @@ -109,7 +110,7 @@ protected Object getValueForProperty(CoreInstance pureObject, Property property, @Override protected Object evaluateQualifiedProperty(CoreInstance pureObject, QualifiedProperty qualifiedProperty, Type type, Multiplicity multiplicity, String propertyName) { - CoreInstance res = ToJson.this.functionExecution.executeFunction(false, qualifiedProperty, Lists.immutable.with(ValueSpecificationBootstrap.wrapValueSpecification(pureObject, true, processorSupport)), new Stack<>(), new Stack<>(), getParentOrEmptyVariableContextForLambda(variableContext, qualifiedProperty), functionExpressionToUseInStack, profiler, instantiationContext, executionSupport); + CoreInstance res = ToJson.this.functionExecution.executeFunction(false, qualifiedProperty, Lists.immutable.with(ValueSpecificationBootstrap.wrapValueSpecification(pureObject, true, processorSupport)), new Stack<>(), new Stack<>(), getParentOrEmptyVariableContextForLambda(variableContext, qualifiedProperty), functionExpressionCallStack, profiler, instantiationContext, executionSupport); if (res instanceof InstanceValue) { return ((InstanceValue) res)._values(); @@ -130,7 +131,7 @@ protected RichIterable getMapKeyValues(CoreInstance pureObject) return KeyValues.executeMap(repository, newPureObjects, processorSupport); } - }, functionExpressionToUseInStack.getSourceInformation()); + }, functionExpressionCallStack.peek().getSourceInformation()); return ValueSpecificationBootstrap.newStringLiteral(this.repository, json, processorSupport); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/pom.xml index 2e1de872bfc..4f54bb15016 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT ../pom.xml diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/src/main/java/org/finos/legend/pure/runtime/java/extension/external/shared/conversion/GenericAndAnyTypeNotSupportedConversion.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/src/main/java/org/finos/legend/pure/runtime/java/extension/external/shared/conversion/GenericAndAnyTypeNotSupportedConversion.java index 0f907e39574..40e48dbac87 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/src/main/java/org/finos/legend/pure/runtime/java/extension/external/shared/conversion/GenericAndAnyTypeNotSupportedConversion.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-conversion/src/main/java/org/finos/legend/pure/runtime/java/extension/external/shared/conversion/GenericAndAnyTypeNotSupportedConversion.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.shared.conversion; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.exception.PureExecutionException; public class GenericAndAnyTypeNotSupportedConversion implements Conversion @@ -23,7 +24,7 @@ public class GenericAndAnyTypeNotSupportedConversion implements Conversion org.finos.legend.engine legend-engine-pure-code-functions-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-shared-functions-json diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonAnyTypeDeserialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonAnyTypeDeserialization.java index bfb30dcf4ff..cbd5910747d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonAnyTypeDeserialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonAnyTypeDeserialization.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.PrimitiveType; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.runtime.java.extension.external.shared.conversion.Conversion; @@ -36,7 +37,7 @@ public Object apply(Object value, ConversionContext context) } catch (IllegalArgumentException e) { - throw new PureExecutionException("Deserialization of Any currently only supported on primitive values!", e); + throw new PureExecutionException("Deserialization of Any currently only supported on primitive values!", e, Stacks.mutable.empty()); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonClassDeserialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonClassDeserialization.java index b3eb9c79249..c73c5564049 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonClassDeserialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonClassDeserialization.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; import org.eclipse.collections.api.set.MutableSet; @@ -114,7 +115,7 @@ public T apply(Object input, ConversionContext context) } catch (PureExecutionException e) { - throw new PureExecutionException(deserializationContext.getSourceInformation(), "Could not create new instance of " + this.pureTypeAsString() + ": \n" + e.getInfo(), e); + throw new PureExecutionException(deserializationContext.getSourceInformation(), "Could not create new instance of " + this.pureTypeAsString() + ": \n" + e.getInfo(), e, Stacks.mutable.empty()); } } @@ -139,12 +140,12 @@ private MutableMap> keyValueProperties(JSONObject jsonOb } catch (PureExecutionException e) { - throw new PureExecutionException(context.getSourceInformation(), "Error populating property '" + jsonPropertyDeserialization.getName() + "' on class '" + this.pureTypeAsString() + "': \n" + e.getInfo(), e); + throw new PureExecutionException(context.getSourceInformation(), "Error populating property '" + jsonPropertyDeserialization.getName() + "' on class '" + this.pureTypeAsString() + "': \n" + e.getInfo(), e, Stacks.mutable.empty()); } catch (ClassCastException | IllegalArgumentException e) { String foundType = jsonValue instanceof JSONObject ? "JSON Object" : PrimitiveConversion.toPurePrimitiveName(jsonValue.getClass()); - throw new PureExecutionException(context.getSourceInformation(), "Error populating property '" + jsonPropertyDeserialization.getName() + "' on class '" + this.pureTypeAsString() + "': \nExpected " + jsonPropertyDeserialization.pureTypeAsString() + ", found " + foundType, e); + throw new PureExecutionException(context.getSourceInformation(), "Error populating property '" + jsonPropertyDeserialization.getName() + "' on class '" + this.pureTypeAsString() + "': \nExpected " + jsonPropertyDeserialization.pureTypeAsString() + ", found " + foundType, e, Stacks.mutable.empty()); } } return keyValues; @@ -165,7 +166,7 @@ private void failOnUnknownProperties(JSONObject jsonValue, JsonDeserializationCo { StringBuilder errorMsg = new StringBuilder(); unknownProperties.forEach(p -> PackageableElement.writeUserPathForPackageableElement(errorMsg.append("Property '").append(p).append("' can't be found in class "), this.clazz).append(". ")); - throw new PureExecutionException(context.getSourceInformation(), errorMsg.toString()); + throw new PureExecutionException(context.getSourceInformation(), errorMsg.toString(), Stacks.mutable.empty()); } } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOne.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOne.java index 0ff8189c486..a028a449ee1 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOne.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOne.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -38,7 +39,7 @@ public RichIterable apply(Object jsonValue, ConversionContext context) { if (!isFromAssociation()) { - throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [1], found 0 value(s)."); + throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [1], found 0 value(s).", Stacks.mutable.empty()); } return Lists.immutable.empty(); } @@ -47,11 +48,11 @@ public RichIterable apply(Object jsonValue, ConversionContext context) JSONArray jsonValues = (JSONArray) jsonValue; if (jsonValues.size() > 1) { - throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [1], found " + jsonValues.size() + " value(s)."); + throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [1], found " + jsonValues.size() + " value(s).", Stacks.mutable.empty()); } if (jsonValues.isEmpty() && !isFromAssociation()) { - throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [1], found 0 value(s)."); + throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [1], found 0 value(s).", Stacks.mutable.empty()); } Object value = ((JSONArray) jsonValue).get(0); return applyConversion(value, jsonDeserializationContext); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOptional.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOptional.java index 463c11d9272..c23f8b106a8 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOptional.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityOptional.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -43,7 +44,7 @@ public RichIterable apply(Object jsonValue, ConversionContext context) JSONArray jsonValues = (JSONArray) jsonValue; if (jsonValues.size() > 1) { - throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [0..1], found " + jsonValues.size() + " value(s)."); + throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity [0..1], found " + jsonValues.size() + " value(s).", Stacks.mutable.empty()); } if (jsonValues.isEmpty()) { diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityParameterised.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityParameterised.java index 26d12fdec58..a04505d914c 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityParameterised.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityParameterised.java @@ -15,6 +15,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -31,6 +32,6 @@ public JsonDeserializationMultiplicityParameterised(AbstractProperty property, b @Override public RichIterable apply(Object value, ConversionContext context) { - throw new PureExecutionException("Deserialization of properties with parameterised multiplicity not supported. Tried to deserialize: "); + throw new PureExecutionException("Deserialization of properties with parameterised multiplicity not supported. Tried to deserialize: ", Stacks.mutable.empty()); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityRange.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityRange.java index 0281ee2cef5..45574a04aed 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityRange.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializationMultiplicityRange.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.multiplicity.Multiplicity; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; @@ -46,7 +47,7 @@ public RichIterable apply(Object jsonValue, ConversionContext context) { if (!isFromAssociation() && (this.lowerBound > 0)) { - throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity " + this.humanReadableMultiplicity + ", found 0 value(s)."); + throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity " + this.humanReadableMultiplicity + ", found 0 value(s).", Stacks.mutable.empty()); } return Lists.immutable.empty(); } @@ -55,7 +56,7 @@ public RichIterable apply(Object jsonValue, ConversionContext context) JSONArray jsonValues = (JSONArray) jsonValue; if ((jsonValues.size() < this.lowerBound) || (jsonValues.size() > this.upperBound)) { - throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity " + this.humanReadableMultiplicity + ", found " + jsonValues.size() + " value(s)."); + throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity " + this.humanReadableMultiplicity + ", found " + jsonValues.size() + " value(s).", Stacks.mutable.empty()); } return applyConversion((JSONArray) jsonValue, jsonDeserializationContext); } @@ -63,7 +64,7 @@ public RichIterable apply(Object jsonValue, ConversionContext context) { if ((this.lowerBound > 1) || (this.upperBound < 1)) { - throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity " + this.humanReadableMultiplicity + ", found 1 value(s)."); + throw new PureExecutionException(jsonDeserializationContext.getSourceInformation(), "Expected value(s) of multiplicity " + this.humanReadableMultiplicity + ", found 1 value(s).", Stacks.mutable.empty()); } return this.applyConversion(jsonValue, jsonDeserializationContext); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializer.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializer.java index b3c38afa31e..d821579b83f 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializer.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonDeserializer.java @@ -15,6 +15,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.set.MutableSet; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Any; @@ -83,7 +84,7 @@ static Type resolveType(Type typeFromPropertyDefinition, Object obj, String type } } } - throw new PureExecutionException(si, String.format("Could not find a sub-type of \"%s\" with name \"%s\".", PackageableElement.getUserPathForPackageableElement(classFromPropertyDefinition), specifiedType)); + throw new PureExecutionException(si, String.format("Could not find a sub-type of \"%s\" with name \"%s\".", PackageableElement.getUserPathForPackageableElement(classFromPropertyDefinition), specifiedType), Stacks.mutable.empty()); } @SuppressWarnings("unchecked") @@ -116,7 +117,7 @@ public static T fromJson(String json, Class clazz, JsonDeseri String java7runtime = "org.json.simple.JSONArray cannot be cast to org.json.simple.JSONObject"; if (java7runtime.equals(e.getMessage()) || java11runtime.equals(e.getMessage())) { - throw new PureExecutionException(context.getSourceInformation(), "Can only deserialize root-level JSONObjects i.e. serialized single instances of PURE classes. Cannot deserialize collections of multiple PURE objects."); + throw new PureExecutionException(context.getSourceInformation(), "Can only deserialize root-level JSONObjects i.e. serialized single instances of PURE classes. Cannot deserialize collections of multiple PURE objects.", Stacks.mutable.empty()); } else { diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonEnumerationDeserialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonEnumerationDeserialization.java index 7bd99db91f1..40faec93e1d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonEnumerationDeserialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonEnumerationDeserialization.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m4.coreinstance.CoreInstance; @@ -35,7 +36,7 @@ public T apply(String jsonValue, ConversionContext context) T value = (T) this.valueMap.get(enumName); if (value == null) { - throw new PureExecutionException(context.getSourceInformation(), "Unknown enum: " + this.enumerationName() + "." + enumName); + throw new PureExecutionException(context.getSourceInformation(), "Unknown enum: " + this.enumerationName() + "." + enumName, Stacks.mutable.empty()); } return value; } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapDeserialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapDeserialization.java index 555f47abb0d..85f449af83d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapDeserialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapDeserialization.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m4.coreinstance.CoreInstance; import org.finos.legend.pure.runtime.java.extension.external.shared.conversion.ConversionContext; @@ -29,6 +30,6 @@ public JsonMapDeserialization() @Override public T apply(Object input, ConversionContext context) { - throw new PureExecutionException("Map deserialization is not currently supported."); + throw new PureExecutionException("Map deserialization is not currently supported.", Stacks.mutable.empty()); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapSerialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapSerialization.java index d7c9e65473a..58486b983fd 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapSerialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonMapSerialization.java @@ -15,6 +15,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.impl.map.mutable.UnifiedMap; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -58,7 +59,7 @@ private static String getKey(CoreInstance keyValuePair, JsonSerializationContext { StringBuilder builder = new StringBuilder("Only String-key map conversions are supported, found key type: "); PackageableElement.writeUserPathForPackageableElement(builder, type); - throw new PureExecutionException(builder.toString()); + throw new PureExecutionException(builder.toString(), Stacks.mutable.empty()); } Conversion keyConcreteConversion = (Conversion)context.getConversionCache().getConversion(TypeCoreInstanceWrapper.toType(type), context); return keyConcreteConversion.apply(context.extractPrimitiveValue(key), context); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonPropertySerialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonPropertySerialization.java index 74af7ffd5af..aebc13c3361 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonPropertySerialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonPropertySerialization.java @@ -15,6 +15,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Stereotype; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Any; @@ -105,7 +106,7 @@ private Object potentiallyEncryptSerializedValue(Object serialized, JsonSerializ } catch (Exception e) { - throw new PureExecutionException("Failed to encrypt serialized json property: " + this.getName() + "\nwith key: " + jsonSerializationContext.getEncryptionKey(), e); + throw new PureExecutionException("Failed to encrypt serialized json property: " + this.getName() + "\nwith key: " + jsonSerializationContext.getEncryptionKey(), e, Stacks.mutable.empty()); } } return serialized; @@ -121,7 +122,7 @@ private Object potentiallyDecryptSerializedValue(Object serialized, JsonSerializ } catch (Exception e) { - throw new PureExecutionException("Failed to decrypt serialized json property: " + this.getName() + "\nwith key: " + jsonSerializationContext.getDecryptionKey(), e); + throw new PureExecutionException("Failed to decrypt serialized json property: " + this.getName() + "\nwith key: " + jsonSerializationContext.getDecryptionKey(), e, Stacks.mutable.empty()); } } return serialized; diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitDeserialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitDeserialization.java index b532af21492..ccf3528af93 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitDeserialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitDeserialization.java @@ -14,6 +14,7 @@ package org.finos.legend.pure.runtime.java.extension.external.json.shared; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Any; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m4.coreinstance.CoreInstance; @@ -43,15 +44,15 @@ public T apply(Object value, ConversionContext context) } catch (Exception e) { - throw new PureExecutionException("Mal-formatted Json for unit.", e); + throw new PureExecutionException("Mal-formatted Json for unit.", e, Stacks.mutable.empty()); } if (unitsJsonArray.size() != 1) { - throw new PureExecutionException("Currently composite units are not supported."); + throw new PureExecutionException("Currently composite units are not supported.", Stacks.mutable.empty()); } if (unitTypeExponent.intValue() != 1) { - throw new PureExecutionException("Currently non-one exponent for unit is not supported. Got: " + unitTypeExponent + "."); + throw new PureExecutionException("Currently non-one exponent for unit is not supported. Got: " + unitTypeExponent + ".", Stacks.mutable.empty()); } Number unitValue; try @@ -60,7 +61,7 @@ public T apply(Object value, ConversionContext context) } catch (ClassCastException e) { - throw new PureExecutionException("Value from unitValue field must be of Number type, getting " + ((JSONObject) value).get(VALUE_KEY_NAME).getClass().getName() + " type instead.", e); + throw new PureExecutionException("Value from unitValue field must be of Number type, getting " + ((JSONObject) value).get(VALUE_KEY_NAME).getClass().getName() + " type instead.", e, Stacks.mutable.empty()); } JsonDeserializationContext deserializationContext = (JsonDeserializationContext) context; @@ -70,7 +71,7 @@ public T apply(Object value, ConversionContext context) } catch (Exception e) { - throw new PureExecutionException(deserializationContext.getSourceInformation(), "Could not create new instance of " + this.pureTypeAsString(), e); + throw new PureExecutionException(deserializationContext.getSourceInformation(), "Could not create new instance of " + this.pureTypeAsString(), e, Stacks.mutable.empty()); } } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitSerialization.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitSerialization.java index 558dc18e937..55049f83d35 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitSerialization.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/legend-engine-pure-runtime-java-extension-shared-functions-json/src/main/java/org/finos/legend/pure/runtime/java/extension/external/json/shared/JsonUnitSerialization.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Unit; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue; @@ -59,6 +60,6 @@ private Number getValue(InstanceValue unitInstance) { return (Number) ((InstanceValue) value)._values().getAny(); } - throw new PureExecutionException("Unexpected unit value: " + value); + throw new PureExecutionException("Unexpected unit value: " + value, Stacks.mutable.empty()); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/pom.xml index 6b1724d0438..bf9297b5d68 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-json/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/pom.xml index 7b9a90485f9..03dc53fa099 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-relation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT Legend Pure - Base - M2 Functions - Relation - Pure diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/relation/TestFunctionsRelationCompiledStateStrategy.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/relation/TestFunctionsRelationCompiledStateIntegrity.java similarity index 89% rename from legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/relation/TestFunctionsRelationCompiledStateStrategy.java rename to legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/relation/TestFunctionsRelationCompiledStateIntegrity.java index d4dea3ea265..325bc7ecc0b 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/relation/TestFunctionsRelationCompiledStateStrategy.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-functions-relation-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/relation/TestFunctionsRelationCompiledStateIntegrity.java @@ -17,11 +17,11 @@ import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; import org.junit.BeforeClass; -public class TestFunctionsRelationCompiledStateStrategy extends AbstractCompiledStateIntegrityTest +public class TestFunctionsRelationCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest { @BeforeClass public static void initialize() { initialize("core_functions_relation"); } -} \ No newline at end of file +} diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/pom.xml index 74bfcd5372d..55139748932 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-compiled-functions-relation/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-relation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-compiled-functions-relation diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/pom.xml index c833d3bfc31..a3416c6c738 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-relation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-interpreted-functions-relation diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/RelationExtensionInterpreted.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/RelationExtensionInterpreted.java index 1a3bfa16a8b..f16139afd7f 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/RelationExtensionInterpreted.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/RelationExtensionInterpreted.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.tuple.Tuples; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function; import org.finos.legend.pure.m3.navigation.Instance; @@ -120,7 +121,7 @@ public static InterpretedExtension extension() } @Override - public CoreInstance getExtraFunctionExecution(Function function, ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, FunctionExecutionInterpreted interpreted) + public CoreInstance getExtraFunctionExecution(Function function, ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, FunctionExecutionInterpreted interpreted) { if (Instance.instanceOf(function, M3Paths.Column, processorSupport)) { diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/AsOfJoin.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/AsOfJoin.java index 419b2b95a63..9006d236bd4 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/AsOfJoin.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/AsOfJoin.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; import org.eclipse.collections.api.set.primitive.MutableIntSet; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.factory.primitive.IntSets; import org.finos.legend.pure.m3.compiler.Context; @@ -52,9 +53,9 @@ public AsOfJoin(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); RelationType relationtype = (RelationType) returnGenericType.getValueForMetaPropertyToMany("typeArguments").get(0).getValueForMetaPropertyToOne("rawType"); CoreInstance matchFunction = Instance.getValueForMetaPropertyToOneResolved(params.get(2), M3Properties.values, processorSupport); @@ -71,8 +72,8 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationtype) + private TestTDS filter(TestTDS tds, CoreInstance filterFunction, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationtype) { LambdaFunction lambdaFunction = (LambdaFunction) LambdaFunctionCoreInstanceWrapper.toLambdaFunction(filterFunction); VariableContext evalVarContext = this.getParentOrEmptyVariableContextForLambda(variableContext, filterFunction); @@ -97,7 +98,7 @@ private TestTDS filter(TestTDS tds, CoreInstance filterFunction, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { RelationType relationType = (RelationType) params.get(0).getValueForMetaPropertyToOne("genericType").getValueForMetaPropertyToMany("typeArguments").getFirst().getValueForMetaPropertyToOne("rawType"); return ValueSpecificationBootstrap.wrapValueSpecification(relationType._columns(), false, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Concatenate.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Concatenate.java index 2e8756cbf06..1671a0f84bc 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Concatenate.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Concatenate.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -43,9 +44,9 @@ public Concatenate(FunctionExecutionInterpreted functionExecution, ModelReposito } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds1 = getTDS(params, 0, processorSupport); TestTDS tds2 = getTDS(params, 1, processorSupport); @@ -55,7 +56,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); Window window = Window.build(params.get(1).getValueForMetaPropertyToOne("values"), processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/DenseRank.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/DenseRank.java index 6e2be5d2747..9713f6e5224 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/DenseRank.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/DenseRank.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.ProcessorSupport; @@ -42,7 +43,7 @@ public DenseRank(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); Window window = Window.build(params.get(1).getValueForMetaPropertyToOne("values"), processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Distinct.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Distinct.java index 6b1cb302882..5d86fc51289 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Distinct.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Distinct.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -44,9 +45,9 @@ public Distinct(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); MutableList columns = params.size() == 1 ? tds.getColumnNames() : Instance.getValueForMetaPropertyToManyResolved(params.get(1), M3Properties.values, processorSupport).flatCollect(c -> c.getValueForMetaPropertyToMany("names")).collect(CoreInstance::getName).toList(); return ValueSpecificationBootstrap.wrapValueSpecification(new TDSCoreInstance(tds.distinct(columns), returnGenericType, repository, processorSupport), false, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Drop.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Drop.java index ef783ceadec..2cc2e3ffbe5 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Drop.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Drop.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.*; @@ -40,9 +41,9 @@ public Drop(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); Number value = PrimitiveUtilities.getIntegerValue(Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport)); return ValueSpecificationBootstrap.wrapValueSpecification(new TDSCoreInstance(tds.slice(value.intValue(), (int)tds.getRowCount()), returnGenericType, repository, processorSupport), false, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Extend.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Extend.java index ded55f23c14..ceed040c42d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Extend.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Extend.java @@ -20,6 +20,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.pure.m3.compiler.Context; @@ -65,11 +66,11 @@ public Extend(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { try { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); @@ -81,26 +82,26 @@ public CoreInstance execute(ListIterable params, Stack) secondParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, (GenericType) params.get(0).getValueForMetaPropertyToOne("genericType"), false)); + result = tds.addColumn(processFuncColSpec(tds.wrapFullTDS(), new Window(new Frame(FrameType.rows, true, true)), (FuncColSpec) secondParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, (GenericType) params.get(0).getValueForMetaPropertyToOne("genericType"), false)); } else if (secondParameter instanceof FuncColSpecArray) { result = ((FuncColSpecArray) secondParameter)._funcSpecs().injectInto( tds, - (a, funcColSpec) -> a.addColumn(processFuncColSpec(tds.wrapFullTDS(), new Window(new Frame(FrameType.rows, true, true)), funcColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, sourceRelationType, false)) + (a, funcColSpec) -> a.addColumn(processFuncColSpec(tds.wrapFullTDS(), new Window(new Frame(FrameType.rows, true, true)), funcColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, sourceRelationType, false)) ); } else if (secondParameter instanceof AggColSpec) { Pair>> source = tds.wrapFullTDS(); - result = tds.addColumn(processOneAggColSpec(source, new Window(new Frame(FrameType.rows, true, true)), (AggColSpec) secondParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, false, null)); + result = tds.addColumn(processOneAggColSpec(source, new Window(new Frame(FrameType.rows, true, true)), (AggColSpec) secondParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, false, null)); } else if (secondParameter instanceof AggColSpecArray) { Pair>> source = tds.wrapFullTDS(); result = ((AggColSpecArray) secondParameter)._aggSpecs().injectInto( source.getOne(), - (a, aggColSpec) -> a.addColumn(processOneAggColSpec(source, new Window(new Frame(FrameType.rows, true, true)), aggColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, false, null)) + (a, aggColSpec) -> a.addColumn(processOneAggColSpec(source, new Window(new Frame(FrameType.rows, true, true)), aggColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, false, null)) ); } else if (Instance.instanceOf(secondParameter, "meta::pure::functions::relation::_Window", processorSupport)) @@ -116,24 +117,24 @@ else if (Instance.instanceOf(secondParameter, "meta::pure::functions::relation:: CoreInstance thirdParameter = Instance.getValueForMetaPropertyToOneResolved(params.get(2), M3Properties.values, processorSupport); if (thirdParameter instanceof AggColSpec) { - result = sortedPartitions.getOne().addColumn(processOneAggColSpec(sortedPartitions, window, (AggColSpec) thirdParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, true, sourceRelationType)); + result = sortedPartitions.getOne().addColumn(processOneAggColSpec(sortedPartitions, window, (AggColSpec) thirdParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, true, sourceRelationType)); } else if (thirdParameter instanceof AggColSpecArray) { result = ((AggColSpecArray) thirdParameter)._aggSpecs().injectInto( sortedPartitions.getOne(), - (a, aggColSpec) -> a.addColumn(processOneAggColSpec(sortedPartitions, window, aggColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, true, sourceRelationType)) + (a, aggColSpec) -> a.addColumn(processOneAggColSpec(sortedPartitions, window, aggColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, false, true, sourceRelationType)) ); } else if (thirdParameter instanceof FuncColSpec) { - result = sortedPartitions.getOne().addColumn(processFuncColSpec(sortedPartitions, window, (FuncColSpec) thirdParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, sourceRelationType, true)); + result = sortedPartitions.getOne().addColumn(processFuncColSpec(sortedPartitions, window, (FuncColSpec) thirdParameter, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, sourceRelationType, true)); } else if (thirdParameter instanceof FuncColSpecArray) { result = ((FuncColSpecArray) thirdParameter)._funcSpecs().injectInto( sortedPartitions.getOne(), - (a, funcColSpec) -> a.addColumn(processFuncColSpec(sortedPartitions, window, funcColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, sourceRelationType, true)) + (a, funcColSpec) -> a.addColumn(processFuncColSpec(sortedPartitions, window, funcColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, sourceRelationType, true)) ); } else @@ -154,7 +155,7 @@ else if (thirdParameter instanceof FuncColSpecArray) } } - private ColumnValue processFuncColSpec(Pair>> source, Window window, FuncColSpec funcColSpec, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, GenericType relationType, boolean twoParamsFunc) + private ColumnValue processFuncColSpec(Pair>> source, Window window, FuncColSpec funcColSpec, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, GenericType relationType, boolean twoParamsFunc) { LambdaFunction lambdaFunction = (LambdaFunction) LambdaFunctionCoreInstanceWrapper.toLambdaFunction(funcColSpec.getValueForMetaPropertyToOne(M3Properties.function)); String name = funcColSpec.getValueForMetaPropertyToOne(M3Properties.name).getName(); @@ -166,7 +167,7 @@ private ColumnValue processFuncColSpec(Pair finalRes[j] = val == null ? null : PrimitiveUtilities.getStringValue(val), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, evalVarContext, twoParamsFunc); + processOneColumn(source, window, lambdaFunction, (j, val) -> finalRes[j] = val == null ? null : PrimitiveUtilities.getStringValue(val), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, evalVarContext, twoParamsFunc); return new ColumnValue(name, DataType.STRING, finalRes); } else if (type == _Package.getByUserPath("Integer", processorSupport)) @@ -174,7 +175,7 @@ else if (type == _Package.getByUserPath("Integer", processorSupport)) int[] finalRes = new int[(int) source.getOne().getRowCount()]; boolean[] nulls = new boolean[(int) source.getOne().getRowCount()]; Arrays.fill(nulls, Boolean.FALSE); - processOneColumn(source, window, lambdaFunction, (j, val) -> processWithNull(j, val, nulls, () -> finalRes[j] = PrimitiveUtilities.getIntegerValue(val).intValue()), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, evalVarContext, twoParamsFunc); + processOneColumn(source, window, lambdaFunction, (j, val) -> processWithNull(j, val, nulls, () -> finalRes[j] = PrimitiveUtilities.getIntegerValue(val).intValue()), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, evalVarContext, twoParamsFunc); return new ColumnValue(name, DataType.INT, finalRes, nulls); } else if (type == _Package.getByUserPath("Float", processorSupport)) @@ -182,7 +183,7 @@ else if (type == _Package.getByUserPath("Float", processorSupport)) double[] finalRes = new double[(int) source.getOne().getRowCount()]; boolean[] nulls = new boolean[(int) source.getOne().getRowCount()]; Arrays.fill(nulls, Boolean.FALSE); - processOneColumn(source, window, lambdaFunction, (j, val) -> processWithNull(j, val, nulls, () -> finalRes[j] = PrimitiveUtilities.getFloatValue(val).doubleValue()), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, evalVarContext, twoParamsFunc); + processOneColumn(source, window, lambdaFunction, (j, val) -> processWithNull(j, val, nulls, () -> finalRes[j] = PrimitiveUtilities.getFloatValue(val).doubleValue()), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, evalVarContext, twoParamsFunc); return new ColumnValue(name, DataType.DOUBLE, finalRes, nulls); } else @@ -210,7 +211,7 @@ private void processWithNull(Integer j, CoreInstance val, boolean[] nulls, Proc } } - private void processOneColumn(Pair>> source, Window window, LambdaFunction lambdaFunction, Procedure2 setter, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, GenericType relationType, VariableContext evalVarContext, boolean twoParamsFunc) + private void processOneColumn(Pair>> source, Window window, LambdaFunction lambdaFunction, Procedure2 setter, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, GenericType relationType, VariableContext evalVarContext, boolean twoParamsFunc) { FixedSizeList parameters = twoParamsFunc ? Lists.fixedSize.with((CoreInstance) null, (CoreInstance) null, (CoreInstance) null) : Lists.fixedSize.with((CoreInstance) null); int k = 0; @@ -226,7 +227,7 @@ private void processOneColumn(Pair>> parameters.set(1, ValueSpecificationBootstrap.wrapValueSpecification(window.convert(processorSupport, new RepoPrimitiveBuilder(repository)), false, processorSupport)); } parameters.set(twoParamsFunc ? 2 : 0, ValueSpecificationBootstrap.wrapValueSpecification(new TDSWithCursorCoreInstance(source.getOne(), i, "", null, relationType, -1, repository, false), false, processorSupport)); - CoreInstance newValue = this.functionExecution.executeFunction(false, lambdaFunction, parameters, resolvedTypeParameters, resolvedMultiplicityParameters, evalVarContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport); + CoreInstance newValue = this.functionExecution.executeFunction(false, lambdaFunction, parameters, resolvedTypeParameters, resolvedMultiplicityParameters, evalVarContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport); setter.value(k++, newValue.getValueForMetaPropertyToOne("values")); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Filter.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Filter.java index 91c9d6d3f14..4892e725f92 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Filter.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Filter.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; import org.eclipse.collections.api.set.primitive.MutableIntSet; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.factory.primitive.IntSets; import org.finos.legend.pure.m3.compiler.Context; @@ -48,9 +49,9 @@ public Filter(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); @@ -65,7 +66,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); RelationType relationType = getRelationType(params, 0); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/GroupBy.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/GroupBy.java index c54dbe518bc..61e94be7e58 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/GroupBy.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/GroupBy.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.api.tuple.Pair; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relation.AggColSpec; @@ -50,9 +51,9 @@ public GroupBy(FunctionExecutionInterpreted functionExecution, ModelRepository r } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); @@ -70,11 +71,11 @@ public CoreInstance execute(ListIterable params, Stack) aggSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, true, false, null)); + result.addColumn(processOneAggColSpec(orderedSource, null, (AggColSpec) aggSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, true, false, null)); } else if (aggSpec instanceof AggColSpecArray) { - result = ((AggColSpecArray) aggSpec)._aggSpecs().injectInto(result, (accResult, aggColSpec) -> accResult.addColumn(processOneAggColSpec(orderedSource, null, aggColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, true, false, null))); + result = ((AggColSpecArray) aggSpec)._aggSpecs().injectInto(result, (accResult, aggColSpec) -> accResult.addColumn(processOneAggColSpec(orderedSource, null, aggColSpec, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, true, false, null))); } else { diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Join.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Join.java index f4b8dad10b2..c821b5f44ba 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Join.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Join.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; import org.eclipse.collections.api.set.primitive.MutableIntSet; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.factory.primitive.IntSets; import org.finos.legend.pure.m3.compiler.Context; @@ -48,9 +49,9 @@ public Join(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds1 = getTDS(params, 0, processorSupport); TestTDS tds2 = getTDS(params, 1, processorSupport); @@ -71,7 +72,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); RelationType relationType = getRelationType(params, 0); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Limit.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Limit.java index 4c6b367643b..3674df44f4b 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Limit.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Limit.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.*; @@ -40,9 +41,9 @@ public Limit(FunctionExecutionInterpreted functionExecution, ModelRepository rep } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); Number value = PrimitiveUtilities.getIntegerValue(Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport)); return ValueSpecificationBootstrap.wrapValueSpecification(new TDSCoreInstance(tds.slice(0, value.intValue()), returnGenericType, repository, processorSupport), false, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Map.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Map.java index 9a2a113d96d..60ced023a31 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Map.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Map.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction; @@ -49,7 +50,7 @@ public Map(FunctionExecutionInterpreted functionExecution, ModelRepository repos } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); @@ -66,12 +67,12 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); TDSWithCursorCoreInstance rc = (TDSWithCursorCoreInstance) params.get(1).getValueForMetaPropertyToOne("values"); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Nth.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Nth.java index fafb0445ee6..687175d20d2 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Nth.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Nth.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relation.RelationType; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -47,7 +48,7 @@ public Nth(FunctionExecutionInterpreted functionExecution, ModelRepository repos } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); RelationType relationType = getRelationType(params, 0); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Offset.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Offset.java index 627972ddebf..ce78a2c7850 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Offset.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Offset.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relation.RelationType; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -45,7 +46,7 @@ public Offset(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); TestTDS nullTDS = tds.newNullTDS(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/PercentRank.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/PercentRank.java index 9aa55978ca1..cf3f6640527 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/PercentRank.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/PercentRank.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.ProcessorSupport; @@ -42,7 +43,7 @@ public PercentRank(FunctionExecutionInterpreted functionExecution, ModelReposito } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); Window window = Window.build(params.get(1).getValueForMetaPropertyToOne("values"), processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Pivot.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Pivot.java index 9a6a3c80dd1..ec8e4d7b86e 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Pivot.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Pivot.java @@ -20,6 +20,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.pure.m3.compiler.Context; @@ -62,7 +63,7 @@ public Pivot(FunctionExecutionInterpreted functionExecution, ModelRepository rep } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); RelationType relationType = getRelationType(params, 0); @@ -122,13 +123,13 @@ else if (aggColSpec instanceof AggColSpecArray) // create the big group-by table by processing all aggregations Pair>> sorted = tds.sort(groupByColumns.collect(c -> new SortInfo(c, SortDirection.ASC))); - TestTDS temp = aggColSpecs.injectInto(null, (a, b) -> processOneAggColSpec(a, b, sorted, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType)); + TestTDS temp = aggColSpecs.injectInto(null, (a, b) -> processOneAggColSpec(a, b, sorted, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType)); // transposing the table to complete pivoting TestTDS result = temp.applyPivot(groupByColumns.reject(pivotCols::contains), pivotCols, aggColSpecs.collect(AggColSpecAccessor::_name)); // populate the generic type for the return at execution time since it cannot be reasoned out at compile time - GenericType returnGenericType = (GenericType) getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + GenericType returnGenericType = (GenericType) getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); returnGenericType._typeArguments(Lists.mutable.with( ((GenericType) processorSupport.newGenericType(null, returnGenericType, true))._rawType(_RelationType.build(result.getColumnWithTypes().collect(c -> { @@ -160,13 +161,13 @@ else if (aggColSpec instanceof AggColSpecArray) throw new RuntimeException("ERROR " + c.getTwo() + " not supported in pivot!"); } return _Column.getColumnInstance(c.getOne(), false, type, (Multiplicity) org.finos.legend.pure.m3.navigation.multiplicity.Multiplicity.newMultiplicity(0, 1, processorSupport), null, processorSupport); - }), functionExpressionToUseInStack.getSourceInformation(), processorSupport)) + }), functionExpressionCallStack.peek().getSourceInformation(), processorSupport)) )); return ValueSpecificationBootstrap.wrapValueSpecification(new TDSCoreInstance(result, returnGenericType, repository, processorSupport), false, processorSupport); } - private TestTDS processOneAggColSpec(TestTDS tds, AggColSpec aggColSpec, Pair>> sorted, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType) + private TestTDS processOneAggColSpec(TestTDS tds, AggColSpec aggColSpec, Pair>> sorted, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType) { String name = aggColSpec.getValueForMetaPropertyToOne("name").getName(); LambdaFunction mapF = (LambdaFunction) LambdaFunctionCoreInstanceWrapper.toLambdaFunction(aggColSpec.getValueForMetaPropertyToOne("map")); @@ -185,28 +186,28 @@ private TestTDS processOneAggColSpec(TestTDS tds, AggColSpec aggColSpec, Pair finalRes[j] = PrimitiveUtilities.getStringValue(val), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, size, parameters, mapFVarContext, reduceFVarContext); + performAggregation(sorted, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getStringValue(val), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, size, parameters, mapFVarContext, reduceFVarContext); resType = DataType.STRING; _finalRes = finalRes; } if (type == _Package.getByUserPath("Integer", processorSupport)) { int[] finalRes = new int[size]; - performAggregation(sorted, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getIntegerValue(val).intValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, size, parameters, mapFVarContext, reduceFVarContext); + performAggregation(sorted, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getIntegerValue(val).intValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, size, parameters, mapFVarContext, reduceFVarContext); resType = DataType.INT; _finalRes = finalRes; } if (type == _Package.getByUserPath("Float", processorSupport)) { double[] finalRes = new double[size]; - performAggregation(sorted, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getFloatValue(val).doubleValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, size, parameters, mapFVarContext, reduceFVarContext); + performAggregation(sorted, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getFloatValue(val).doubleValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, size, parameters, mapFVarContext, reduceFVarContext); resType = DataType.FLOAT; _finalRes = finalRes; } return tds == null ? sorted.getOne()._distinct(sorted.getTwo()).addColumn(name, resType, _finalRes) : tds.addColumn(name, resType, _finalRes); } - private void performAggregation(Pair>> res, LambdaFunction mapF, LambdaFunction reduceF, Procedure2 setter, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType, int size, FixedSizeList parameters, VariableContext mapFVarContext, VariableContext reduceFVarContext) + private void performAggregation(Pair>> res, LambdaFunction mapF, LambdaFunction reduceF, Procedure2 setter, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType, int size, FixedSizeList parameters, VariableContext mapFVarContext, VariableContext reduceFVarContext) { for (int j = 0; j < size; j++) { @@ -215,10 +216,10 @@ private void performAggregation(Pair for (int i = r.getOne(); i < r.getTwo(); i++) { parameters.set(0, ValueSpecificationBootstrap.wrapValueSpecification(new TDSWithCursorCoreInstance(res.getOne(), i, "", null, relationType, -1, repository, false), true, processorSupport)); - subList.add(this.functionExecution.executeFunction(false, mapF, parameters, resolvedTypeParameters, resolvedMultiplicityParameters, mapFVarContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport).getValueForMetaPropertyToOne("values")); + subList.add(this.functionExecution.executeFunction(false, mapF, parameters, resolvedTypeParameters, resolvedMultiplicityParameters, mapFVarContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport).getValueForMetaPropertyToOne("values")); } parameters.set(0, ValueSpecificationBootstrap.wrapValueSpecification(subList, true, processorSupport)); - CoreInstance re = this.functionExecution.executeFunction(false, reduceF, parameters, resolvedTypeParameters, resolvedMultiplicityParameters, reduceFVarContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport); + CoreInstance re = this.functionExecution.executeFunction(false, reduceF, parameters, resolvedTypeParameters, resolvedMultiplicityParameters, reduceFVarContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport); setter.value(j, re.getValueForMetaPropertyToOne("values")); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Project.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Project.java index 8b4bc1a2347..7807be11d2e 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Project.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Project.java @@ -19,6 +19,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.tuple.Tuples; @@ -55,9 +56,9 @@ public Project(FunctionExecutionInterpreted functionExecution, ModelRepository r } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); ListIterable values = Instance.getValueForMetaPropertyToManyResolved(params.get(0), M3Properties.values, processorSupport); @@ -88,7 +89,7 @@ public CoreInstance execute(ListIterable params, Stack valExtractor = getExtractor(processorSupport, type); - CoreInstance subResult = this.functionExecution.executeFunction(false, fInfo.getOne(), parameters, resolvedTypeParameters, resolvedMultiplicityParameters, fInfo.getTwo(), functionExpressionToUseInStack, profiler, instantiationContext, executionSupport); + CoreInstance subResult = this.functionExecution.executeFunction(false, fInfo.getOne(), parameters, resolvedTypeParameters, resolvedMultiplicityParameters, fInfo.getTwo(), functionExpressionCallStack, profiler, instantiationContext, executionSupport); subResult.getValueForMetaPropertyToMany("values").forEach(c -> vals.add(valExtractor.apply(c))); if (type == _Package.getByUserPath("String", processorSupport)) diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rank.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rank.java index 4e21bf7eef1..7bb2bdb8523 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rank.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rank.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.ProcessorSupport; @@ -42,7 +43,7 @@ public Rank(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); Window window = Window.build(params.get(1).getValueForMetaPropertyToOne("values"), processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rename.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rename.java index 9bc83c0a022..2a689d1190f 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rename.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Rename.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.*; @@ -40,9 +41,9 @@ public Rename(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); String oldName = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getValueForMetaPropertyToOne("name").getName(); String newName = Instance.getValueForMetaPropertyToOneResolved(params.get(2), M3Properties.values, processorSupport).getValueForMetaPropertyToOne("name").getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/RowNumber.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/RowNumber.java index 589395bb156..58ecc14c324 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/RowNumber.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/RowNumber.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.ProcessorSupport; @@ -40,7 +41,7 @@ public RowNumber(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TDSWithCursorCoreInstance rc = (TDSWithCursorCoreInstance) params.get(1).getValueForMetaPropertyToOne("values"); return ValueSpecificationBootstrap.wrapValueSpecification(this.repository.newIntegerCoreInstance(rc.getCurrentRow() + 1), true, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Select.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Select.java index a8dce4bd314..6c70a11d955 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Select.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Select.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relation.ColSpec; @@ -46,9 +47,9 @@ public Select(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Size.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Size.java index 6397b6189e6..f4c94d9b7bf 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Size.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Size.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.ProcessorSupport; @@ -40,7 +41,7 @@ public Size(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { TestTDS tds = getTDS(params, 0, processorSupport); return ValueSpecificationBootstrap.wrapValueSpecification(this.repository.newIntegerCoreInstance(tds.getRowCount()), true, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Slice.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Slice.java index fe47599c27a..a1e35a0e735 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Slice.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Slice.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.*; @@ -40,9 +41,9 @@ public Slice(FunctionExecutionInterpreted functionExecution, ModelRepository rep } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); Number from = PrimitiveUtilities.getIntegerValue(Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport)); Number to = PrimitiveUtilities.getIntegerValue(Instance.getValueForMetaPropertyToOneResolved(params.get(2), M3Properties.values, processorSupport)); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Sort.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Sort.java index 4e7e36ce6ae..a40696b9685 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Sort.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/Sort.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -45,9 +46,9 @@ public Sort(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { - CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, processorSupport); + CoreInstance returnGenericType = getReturnGenericType(resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, processorSupport); TestTDS tds = getTDS(params, 0, processorSupport); ListIterable sortInfos = getSortInfos(Instance.getValueForMetaPropertyToManyResolved(params.get(1), M3Properties.values, processorSupport), processorSupport); return ValueSpecificationBootstrap.wrapValueSpecification(new TDSCoreInstance(tds.sort(sortInfos).getOne(), returnGenericType, repository, processorSupport), false, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/AggregationShared.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/AggregationShared.java index 4875ea0151d..39d1c827246 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/AggregationShared.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/AggregationShared.java @@ -20,6 +20,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction; @@ -58,7 +59,7 @@ public AggregationShared(FunctionExecutionInterpreted functionExecution, ModelRe super(functionExecution, repository); } - protected ColumnValue processOneAggColSpec(Pair>> aggregationScope, Window window, AggColSpec aggColSpec, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType, boolean compress, boolean twoParamsFunc, GenericType sourceTDSType) + protected ColumnValue processOneAggColSpec(Pair>> aggregationScope, Window window, AggColSpec aggColSpec, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType, boolean compress, boolean twoParamsFunc, GenericType sourceTDSType) { String name = aggColSpec.getValueForMetaPropertyToOne("name").getName(); LambdaFunction mapF = (LambdaFunction) LambdaFunctionCoreInstanceWrapper.toLambdaFunction(aggColSpec.getValueForMetaPropertyToOne("map")); @@ -73,19 +74,19 @@ protected ColumnValue processOneAggColSpec(Pair finalRes[j] = PrimitiveUtilities.getStringValue(val), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, mapFVarContext, reduceFVarContext, compress, twoParamsFunc, sourceTDSType); + performAggregation(aggregationScope, window, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getStringValue(val), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, mapFVarContext, reduceFVarContext, compress, twoParamsFunc, sourceTDSType); return new ColumnValue(name, DataType.STRING, finalRes); } else if (type == _Package.getByUserPath("Integer", processorSupport)) { int[] finalRes = new int[size]; - performAggregation(aggregationScope, window, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getIntegerValue(val).intValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, mapFVarContext, reduceFVarContext, compress, twoParamsFunc, sourceTDSType); + performAggregation(aggregationScope, window, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getIntegerValue(val).intValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, mapFVarContext, reduceFVarContext, compress, twoParamsFunc, sourceTDSType); return new ColumnValue(name, DataType.INT, finalRes); } else if (type == _Package.getByUserPath("Float", processorSupport) || type == _Package.getByUserPath("Number", processorSupport)) { double[] finalRes = new double[size]; - performAggregation(aggregationScope, window, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getFloatValue(val).doubleValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, mapFVarContext, reduceFVarContext, compress, twoParamsFunc, sourceTDSType); + performAggregation(aggregationScope, window, mapF, reduceF, (j, val) -> finalRes[j] = PrimitiveUtilities.getFloatValue(val).doubleValue(), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, relationType, mapFVarContext, reduceFVarContext, compress, twoParamsFunc, sourceTDSType); return new ColumnValue(name, DataType.FLOAT, finalRes); } else @@ -94,7 +95,7 @@ else if (type == _Package.getByUserPath("Float", processorSupport) || type == _P } } - protected void performAggregation(Pair>> orderedSource, Window window, LambdaFunction mapF, LambdaFunction reduceF, Procedure2 setter, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType, VariableContext mapFVarContext, VariableContext reduceFVarContext, boolean compress, boolean twoParamFunc, GenericType sourceTDSType) + protected void performAggregation(Pair>> orderedSource, Window window, LambdaFunction mapF, LambdaFunction reduceF, Procedure2 setter, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, RelationType relationType, VariableContext mapFVarContext, VariableContext reduceFVarContext, boolean compress, boolean twoParamFunc, GenericType sourceTDSType) { FixedSizeList mapParameters = twoParamFunc ? Lists.fixedSize.with((CoreInstance) null,(CoreInstance) null, (CoreInstance) null) : Lists.fixedSize.with((CoreInstance) null); FixedSizeList reduceParameters = Lists.fixedSize.with((CoreInstance) null); @@ -113,14 +114,14 @@ protected void performAggregation(Pair l = framedList(subList, window.getFrame(), i); l.removeIf(Objects::isNull); reduceParameters.set(0, ValueSpecificationBootstrap.wrapValueSpecification(l, true, processorSupport)); - CoreInstance re = this.functionExecution.executeFunction(false, reduceF, reduceParameters, resolvedTypeParameters, resolvedMultiplicityParameters, reduceFVarContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport); + CoreInstance re = this.functionExecution.executeFunction(false, reduceF, reduceParameters, resolvedTypeParameters, resolvedMultiplicityParameters, reduceFVarContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport); setter.value(r.getOne() + i, re.getValueForMetaPropertyToOne("values")); } } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/Shared.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/Shared.java index 012d7ae60ba..c35fc722552 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/Shared.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/main/java/org/finos/legend/pure/runtime/java/extension/external/relation/interpreted/natives/shared/Shared.java @@ -19,6 +19,7 @@ import io.deephaven.csv.sinks.SinkFactory; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relation.RelationType; import org.finos.legend.pure.m3.navigation.ProcessorSupport; import org.finos.legend.pure.m3.navigation.generictype.GenericType; @@ -59,9 +60,9 @@ public RelationType getRelationType(ListIterable para return (RelationType) params.get(i).getValueForMetaPropertyToOne("genericType").getValueForMetaPropertyToMany("typeArguments").getFirst().getValueForMetaPropertyToOne("rawType"); } - public static CoreInstance getReturnGenericType(Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, CoreInstance functionExpressionToUseInStack, ProcessorSupport processorSupport) + public static CoreInstance getReturnGenericType(Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, MutableStack functionExpressionCallStack, ProcessorSupport processorSupport) { - return GenericType.makeTypeArgumentAsConcreteAsPossible(functionExpressionToUseInStack.getValueForMetaPropertyToOne("genericType"), resolvedTypeParameters.get(0), resolvedMultiplicityParameters.get(0), processorSupport); + return GenericType.makeTypeArgumentAsConcreteAsPossible(functionExpressionCallStack.peek().getValueForMetaPropertyToOne("genericType"), resolvedTypeParameters.get(0), resolvedMultiplicityParameters.get(0), processorSupport); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/interpreted/pure/TestFunctionTester.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/interpreted/pure/TestFunctionTester.java index 11bf8513d03..9cc5885908e 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/interpreted/pure/TestFunctionTester.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-interpreted-functions-relation/src/test/java/org/finos/legend/pure/runtime/java/extension/relation/interpreted/pure/TestFunctionTester.java @@ -260,24 +260,24 @@ public void testFunction() // // //-------------------------------------------------------------------- // - compileTestSource("fromString.pure", - "function test():Any[*]\n" + - "{ " + - " let tds = #TDS\n" + - " id, name\n" + - " 1, George\n" + - " 2, Pierre\n" + - " 3, Sachin\n" + - " 4, David\n" + - " #;\n" + - "\n" + - " print(" + - " $tds->drop(3)->size()" + - " ,2);" + - "}\n"); - this.execute("test():Any[*]"); - runtime.delete("fromString.pure"); -// +// compileTestSource("fromString.pure", +// "function test():Any[*]\n" + +// "{ " + +// " let tds = #TDS\n" + +// " id, name\n" + +// " 1, George\n" + +// " 2, Pierre\n" + +// " 3, Sachin\n" + +// " 4, David\n" + +// " #;\n" + +// "\n" + +// " print(" + +// " $tds->drop(3)->size()" + +// " ,2);" + +// "}\n"); +// this.execute("test():Any[*]"); +// runtime.delete("fromString.pure"); +//// // //-------------------------------------------------------------------- // // compileTestSource("fromString.pure", diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-shared-functions-relation/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-shared-functions-relation/pom.xml index 8faba48e562..2e841fd7a09 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-shared-functions-relation/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/legend-engine-pure-runtime-java-extension-shared-functions-relation/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-relation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-shared-functions-relation diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/pom.xml index f3ae08b01da..5c93a8d21d4 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-relation/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/pom.xml index 1cbe4e72f12..91e4a22d39c 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-standard - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-functions-standard-pure diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/standard/TestFunctionsStandardCompiledStateStrategy.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/standard/TestFunctionsStandardCompiledStateIntegrity.java similarity index 89% rename from legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/standard/TestFunctionsStandardCompiledStateStrategy.java rename to legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/standard/TestFunctionsStandardCompiledStateIntegrity.java index 22f24494570..c0065eee941 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/standard/TestFunctionsStandardCompiledStateStrategy.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/legend-engine-pure-functions-standard-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/standard/TestFunctionsStandardCompiledStateIntegrity.java @@ -17,11 +17,11 @@ import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; import org.junit.BeforeClass; -public class TestFunctionsStandardCompiledStateStrategy extends AbstractCompiledStateIntegrityTest +public class TestFunctionsStandardCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest { @BeforeClass public static void initialize() { initialize("core_functions_standard"); } -} \ No newline at end of file +} diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/pom.xml index 05d4c80f603..067ca5b975f 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-standard/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/pom.xml index 91b7bb27dd3..b1c10d11250 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-unclassified - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT Legend Pure - Base - M2 Functions - Base - Pure diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/unclassified/TestFunctionsUnclassifiedCompiledStateStrategy.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/unclassified/TestFunctionsUnclassifiedCompiledStateIntegrity.java similarity index 89% rename from legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/unclassified/TestFunctionsUnclassifiedCompiledStateStrategy.java rename to legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/unclassified/TestFunctionsUnclassifiedCompiledStateIntegrity.java index 4e261ba519b..16556488f75 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/unclassified/TestFunctionsUnclassifiedCompiledStateStrategy.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-functions-unclassified-pure/src/test/java/org/finos/legend/engine/pure/code/core/functions/unclassified/TestFunctionsUnclassifiedCompiledStateIntegrity.java @@ -17,11 +17,11 @@ import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; import org.junit.BeforeClass; -public class TestFunctionsUnclassifiedCompiledStateStrategy extends AbstractCompiledStateIntegrityTest +public class TestFunctionsUnclassifiedCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest { @BeforeClass public static void initialize() { initialize("core_functions_unclassified"); } -} \ No newline at end of file +} diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/pom.xml index d8c08582253..15a146e5402 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-unclassified - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-compiled-functions-unclassified diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsHelper.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsHelper.java index b182269ad3d..bca98d35d26 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsHelper.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsHelper.java @@ -23,6 +23,7 @@ import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.block.procedure.Procedure; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; import org.eclipse.collections.impl.lazy.AbstractLazyIterable; @@ -97,7 +98,7 @@ private static String performEncryption(String value, String key) } catch (Exception e) { - throw new PureExecutionException("Error ciphering value '" + value + "' with key '" + key + "'.", e); + throw new PureExecutionException("Error ciphering value '" + value + "' with key '" + key + "'.", e, Stacks.mutable.empty()); } } @@ -109,7 +110,7 @@ public static String decrypt(String value, String key) } catch (Exception e) { - throw new PureExecutionException("Error deciphering value '" + value + "' with key '" + key + "'.", e); + throw new PureExecutionException("Error deciphering value '" + value + "' with key '" + key + "'.", e, Stacks.mutable.empty()); } } // Crypto ---------------------------------------------------------------- @@ -130,7 +131,7 @@ public static long weekOfYear(PureDate date, SourceInformation sourceInformation { if (!date.hasDay()) { - throw new PureExecutionException(sourceInformation, "Cannot get week of year for " + date); + throw new PureExecutionException(sourceInformation, "Cannot get week of year for " + date, Stacks.mutable.empty()); } return date.getCalendar().get(Calendar.WEEK_OF_YEAR); } @@ -139,7 +140,7 @@ public static long dayOfYear(PureDate date, SourceInformation sourceInformation) { if (!date.hasDay()) { - throw new PureExecutionException(sourceInformation, "Cannot get day of year for " + date); + throw new PureExecutionException(sourceInformation, "Cannot get day of year for " + date, Stacks.mutable.empty()); } return date.getCalendar().get(Calendar.DAY_OF_YEAR); } @@ -148,7 +149,7 @@ public static long dayOfWeekNumber(PureDate date, SourceInformation sourceInform { if (!date.hasDay()) { - throw new PureExecutionException(sourceInformation, "Cannot get day of week for " + date); + throw new PureExecutionException(sourceInformation, "Cannot get day of week for " + date, Stacks.mutable.empty()); } switch (date.getCalendar().get(Calendar.DAY_OF_WEEK)) { @@ -182,7 +183,7 @@ public static long dayOfWeekNumber(PureDate date, SourceInformation sourceInform } default: { - throw new PureExecutionException(sourceInformation, "Error getting day of week for " + date); + throw new PureExecutionException(sourceInformation, "Error getting day of week for " + date, Stacks.mutable.empty()); } } } @@ -243,7 +244,7 @@ public static String functionDescriptorToId(String functionDescriptor, SourceInf } catch (InvalidFunctionDescriptorException e) { - throw new PureExecutionException(sourceInformation, "Invalid function descriptor: " + functionDescriptor, e); + throw new PureExecutionException(sourceInformation, "Invalid function descriptor: " + functionDescriptor, e, Stacks.mutable.empty()); } } @@ -336,7 +337,7 @@ public static RichIterable chunk(String text, long size, SourceInformati { if (size < 1) { - throw new PureExecutionException(sourceInformation, "Invalid chunk size: " + size); + throw new PureExecutionException(sourceInformation, "Invalid chunk size: " + size, Stacks.mutable.empty()); } return chunk(text, (int) size); } @@ -472,7 +473,7 @@ public static T mutateAdd(T val, String property, RichIterable vals, Sour } catch (NoSuchMethodException e) { - throw new PureExecutionException(sourceInformation, "Cannot find property '" + property + "' on " + CompiledSupport.getPureGeneratedClassName(val)); + throw new PureExecutionException(sourceInformation, "Cannot find property '" + property + "' on " + CompiledSupport.getPureGeneratedClassName(val), Stacks.mutable.empty()); } catch (Exception e) { @@ -569,7 +570,7 @@ public static Object alloyTest(ExecutionSupport es, Function alloyTest, Funct long port = System.getProperty("alloy.test.server.port") == null ? -1 : Long.parseLong(System.getProperty("alloy.test.server.port")); if (host != null && port == -1) { - throw new PureExecutionException("The system variable 'alloy.test.server.host' is set to '" + host + "' however 'alloy.test.server.port' has not been set!"); + throw new PureExecutionException("The system variable 'alloy.test.server.host' is set to '" + host + "' however 'alloy.test.server.port' has not been set!", Stacks.mutable.empty()); } String clientVersion = System.getProperty("alloy.test.clientVersion"); String serverVersion = System.getProperty("alloy.test.serverVersion"); @@ -587,7 +588,7 @@ public static Object legendTest(ExecutionSupport es, Function alloyTest, Func { if (port == -1) { - throw new PureExecutionException("The system variable 'legend.test.server.host' is set to '" + host + "' however 'legend.test.server.port' has not been set!"); + throw new PureExecutionException("The system variable 'legend.test.server.host' is set to '" + host + "' however 'legend.test.server.port' has not been set!", Stacks.mutable.empty()); } if (serializationKind == null || !(serializationKind.equals("text") || serializationKind.equals("json"))) { @@ -595,11 +596,11 @@ public static Object legendTest(ExecutionSupport es, Function alloyTest, Func } if (clientVersion == null) { - throw new PureExecutionException("The system variable 'legend.test.clientVersion' should be set"); + throw new PureExecutionException("The system variable 'legend.test.clientVersion' should be set", Stacks.mutable.empty()); } if (serverVersion == null) { - throw new PureExecutionException("The system variable 'legend.test.serverVersion' should be set"); + throw new PureExecutionException("The system variable 'legend.test.serverVersion' should be set", Stacks.mutable.empty()); } } return host != null ? Pure.evaluate(es, alloyTest, bridge, clientVersion, serverVersion, serializationKind, host, port) : Pure.evaluate(es, regular, bridge); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/resources/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsGen.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/resources/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsGen.java index 79208946661..82c676df48c 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/resources/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsGen.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-compiled-functions-unclassified/src/main/resources/org/finos/legend/pure/runtime/java/extension/functions/compiled/FunctionsGen.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.finos.legend.pure.m3.coreinstance.Package; @@ -120,7 +121,7 @@ public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Cla ListIterable fullPath = PackageableElement.splitUserPath(fullPathString); if (fullPath.isEmpty()) { - throw new PureExecutionException(null, "Cannot create a new Class: '" + fullPathString + "'"); + throw new PureExecutionException(null, "Cannot create a new Class: '" + fullPathString + "'", Stacks.mutable.empty()); } String name = fullPath.getLast(); org.finos.legend.pure.m3.coreinstance.Package _package = Pure.buildPackageIfNonExistent(new Package_Impl("Root")._name("Root"), fullPath.subList(0, fullPath.size() - 1), si, new DefendedFunction() @@ -147,7 +148,7 @@ public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relation ListIterable fullPath = PackageableElement.splitUserPath(fullPathString); if (fullPath.isEmpty()) { - throw new PureExecutionException(null, "Cannot create a new Association: '" + fullPathString + "'"); + throw new PureExecutionException(null, "Cannot create a new Association: '" + fullPathString + "'", Stacks.mutable.empty()); } String name = fullPath.getLast(); org.finos.legend.pure.m3.coreinstance.Package _package = Pure.buildPackageIfNonExistent(new Package_Impl("Root")._name("Root"), fullPath.subList(0, fullPath.size() - 1), si, new DefendedFunction() @@ -169,7 +170,7 @@ public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enu ListIterable fullPath = PackageableElement.splitUserPath(fullPathString); if (fullPath.isEmpty()) { - throw new PureExecutionException(null, "Cannot create a new Enumeration: '" + fullPathString + "'"); + throw new PureExecutionException(null, "Cannot create a new Enumeration: '" + fullPathString + "'", Stacks.mutable.empty()); } String name = fullPath.getLast(); String packageName = fullPath.subList(0, fullPath.size() - 1).makeString("::"); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/pom.xml index 8a380f4df40..610a648eb8f 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-unclassified - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/AlloyTest.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/AlloyTest.java index 6385dd226cb..57a5738f9ae 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/AlloyTest.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/AlloyTest.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.FunctionCoreInstanceWrapper; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -48,7 +49,7 @@ public AlloyTest(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, final ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, final ProcessorSupport processorSupport) throws PureExecutionException { String clientVersion = System.getProperty("alloy.test.clientVersion"); String serverVersion = System.getProperty("alloy.test.serverVersion"); @@ -59,15 +60,15 @@ public CoreInstance execute(ListIterable params, Stack fParams = Lists.mutable.with( ValueSpecificationBootstrap.newStringLiteral(this.repository, clientVersion, this.functionExecution.getProcessorSupport()), @@ -80,7 +81,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String clientVersion = System.getProperty("legend.test.clientVersion"); String serverVersion = System.getProperty("legend.test.serverVersion"); @@ -60,7 +61,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack fParams = Lists.mutable.with( ValueSpecificationBootstrap.newStringLiteral(this.repository, clientVersion, this.functionExecution.getProcessorSupport()), @@ -86,7 +87,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { ActiveProfiler activeProfiler = new ActiveProfiler(processorSupport, PrimitiveUtilities.getBooleanValue(params.get(1).getValueForMetaPropertyToOne(M3Properties.values))); - activeProfiler.start(functionExpressionToUseInStack); - CoreInstance result = this.functionExecution.executeValueSpecification(params.get(0), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionToUseInStack, + activeProfiler.start(functionExpressionCallStack.peek()); + CoreInstance result = this.functionExecution.executeValueSpecification(params.get(0), resolvedTypeParameters, resolvedMultiplicityParameters, functionExpressionCallStack, this.getParentOrEmptyVariableContext(variableContext), activeProfiler, instantiationContext, executionSupport); - activeProfiler.end(functionExpressionToUseInStack); - this.print.execute(Lists.immutable.with(ValueSpecificationBootstrap.newStringLiteral(this.repository, activeProfiler.getReport(), processorSupport), ValueSpecificationBootstrap.newIntegerLiteral(this.repository, PRINT_DEPTH, processorSupport)), resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, context, processorSupport); + activeProfiler.end(functionExpressionCallStack.peek()); + this.print.execute(Lists.immutable.with(ValueSpecificationBootstrap.newStringLiteral(this.repository, activeProfiler.getReport(), processorSupport), ValueSpecificationBootstrap.newIntegerLiteral(this.repository, PRINT_DEPTH, processorSupport)), resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, context, processorSupport); CoreInstance profileResultType = processorSupport.package_getByUserPath("meta::pure::functions::tools::ProfileResult"); CoreInstance profileResult = this.repository.newEphemeralAnonymousCoreInstance(null, profileResultType); CoreInstance genericTypeType = processorSupport.package_getByUserPath(M3Paths.GenericType); - CoreInstance classifierGenericType = this.repository.newAnonymousCoreInstance(functionExpressionToUseInStack.getSourceInformation(), genericTypeType); + CoreInstance classifierGenericType = this.repository.newAnonymousCoreInstance(functionExpressionCallStack.peek().getSourceInformation(), genericTypeType); Instance.addValueToProperty(classifierGenericType, M3Properties.rawType, profileResultType, processorSupport); CoreInstance T = Instance.extractGenericTypeFromInstance(result, processorSupport); Instance.addValueToProperty(classifierGenericType, M3Properties.typeArguments, T, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/cipher/Cipher.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/cipher/Cipher.java index 999a70c98a4..35b32463ea9 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/cipher/Cipher.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/cipher/Cipher.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.compiler.Context; @@ -44,7 +45,7 @@ public Cipher(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String value = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String key = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); @@ -56,7 +57,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String value = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String key = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); @@ -56,7 +57,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { ListIterable values = Instance.getValueForMetaPropertyToManyResolved(params.get(0), M3Properties.values, processorSupport); String key = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/collection/Repeat.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/collection/Repeat.java index c9e5ba5f6ce..12f60b1d325 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/collection/Repeat.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/collection/Repeat.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.list.mutable.FastList; import org.finos.legend.pure.m3.navigation.M3Properties; @@ -44,7 +45,7 @@ public Repeat(FunctionExecutionInterpreted functionExecution, ModelRepository re } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { int n = PrimitiveUtilities.getIntegerValue(Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport)).intValue(); if (n == 1) diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/date/NativeDateIndexicalFunction.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/date/NativeDateIndexicalFunction.java index 598f044cbd5..b64fc44cefd 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/date/NativeDateIndexicalFunction.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/date/NativeDateIndexicalFunction.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.ValueSpecificationBootstrap; @@ -41,7 +42,7 @@ protected NativeDateIndexicalFunction(ModelRepository repository) } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { return ValueSpecificationBootstrap.newDateLiteral(this.repository, getDate(), processorSupport); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/hash/Hash.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/hash/Hash.java index ebcad23e850..0351749567b 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/hash/Hash.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/hash/Hash.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.compiler.Context; @@ -46,7 +47,7 @@ public Hash(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { // Parameter 0: text String text = PrimitiveUtilities.getStringValue(Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport)); @@ -64,7 +65,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String filePath = PrimitiveUtilities.getStringValue(params.get(0).getValueForMetaPropertyToOne(M3Properties.values)); if ((this.codeStorage == null) || !this.codeStorage.exists(filePath)) diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/io/http/Http.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/io/http/Http.java index a0be59cb816..cbdd623a55a 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/io/http/Http.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/io/http/Http.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.Instance; import org.finos.legend.pure.m3.navigation.M3Properties; @@ -47,7 +48,7 @@ public Http(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { // URL: param 0 CoreInstance urlInstance = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/lang/MutateAdd.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/lang/MutateAdd.java index 2938c7f0070..b4ad56fc09a 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/lang/MutateAdd.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/lang/MutateAdd.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -39,7 +40,7 @@ public MutateAdd(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance obj = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport); String propertyName = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/CompileValueSpecification.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/CompileValueSpecification.java index 7238e13a482..96752e863ba 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/CompileValueSpecification.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/CompileValueSpecification.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.list.mutable.FastList; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.compiler.Context; @@ -54,7 +55,7 @@ public CompileValueSpecification(FunctionExecutionInterpreted functionExecution, } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { ListIterable codeBlocks = Instance.getValueForMetaPropertyToManyResolved(params.get(0), M3Properties.values, processorSupport); MutableList results = FastList.newList(codeBlocks.size()); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/FunctionDescriptorToId.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/FunctionDescriptorToId.java index 22eb8eee484..e529a865907 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/FunctionDescriptorToId.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/FunctionDescriptorToId.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.compiler.Context; @@ -45,7 +46,7 @@ public FunctionDescriptorToId(FunctionExecutionInterpreted functionExecution, Mo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String functionDescriptor = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String id = null; @@ -55,7 +56,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { return ValueSpecificationBootstrap.newBooleanLiteral(this.pureRuntime.getModelRepository(), this.pureRuntime.isSourceImmutable(Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName()), processorSupport); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/IsValidFunctionDescriptor.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/IsValidFunctionDescriptor.java index fbc61f2d047..acf4ba30da0 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/IsValidFunctionDescriptor.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/IsValidFunctionDescriptor.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.compiler.Context; @@ -44,7 +45,7 @@ public IsValidFunctionDescriptor(FunctionExecutionInterpreted functionExecution, } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String possiblyFunctionDescriptor = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); boolean isValidFunctionDescriptor = FunctionDescriptor.isValidFunctionDescriptor(possiblyFunctionDescriptor); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewAssociation.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewAssociation.java index f5b201aea5f..cfddee59cfd 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewAssociation.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewAssociation.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.compiler.postprocessing.PostProcessor; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -51,13 +52,13 @@ public NewAssociation(FunctionExecutionInterpreted functionExecution, ModelRepos } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String fullPathString = PrimitiveUtilities.getStringValue(Instance.getValueForMetaPropertyToOneResolved(params.getFirst(), M3Properties.values, processorSupport)); ListIterable fullPath = PackageableElement.splitUserPath(fullPathString); if (fullPath.isEmpty()) { - throw new PureExecutionException(functionExpressionToUseInStack.getSourceInformation(), "Cannot create a new Association: '" + fullPathString + "'"); + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), "Cannot create a new Association: '" + fullPathString + "'", functionExpressionCallStack); } String name = fullPath.getLast(); CoreInstance pack = _Package.findOrCreatePackageFromUserPath(fullPath.subList(0, fullPath.size() - 1), this.repository, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewClass.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewClass.java index 5ff5df76e81..1135f2171f6 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewClass.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewClass.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -48,13 +49,13 @@ public NewClass(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String fullPathString = PrimitiveUtilities.getStringValue(Instance.getValueForMetaPropertyToOneResolved(params.getFirst(), M3Properties.values, processorSupport)); ListIterable fullPath = PackageableElement.splitUserPath(fullPathString); if (fullPath.isEmpty()) { - throw new PureExecutionException(functionExpressionToUseInStack.getSourceInformation(), "Cannot create a new Class: '" + fullPathString + "'"); + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), "Cannot create a new Class: '" + fullPathString + "'", functionExpressionCallStack); } String name = fullPath.getLast(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewEnumeration.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewEnumeration.java index 3b638586e14..062cdd6a535 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewEnumeration.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewEnumeration.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -48,13 +49,13 @@ public NewEnumeration(FunctionExecutionInterpreted functionExecution, ModelRepos } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String fullPathString = PrimitiveUtilities.getStringValue(Instance.getValueForMetaPropertyToOneResolved(params.getFirst(), M3Properties.values, processorSupport)); ListIterable fullPath = PackageableElement.splitUserPath(fullPathString); if (fullPath.isEmpty()) { - throw new PureExecutionException(functionExpressionToUseInStack.getSourceInformation(), "Cannot create a new Enumeration: '" + fullPathString + "'"); + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), "Cannot create a new Enumeration: '" + fullPathString + "'", functionExpressionCallStack); } String name = fullPath.getLast(); CoreInstance pack = _Package.findOrCreatePackageFromUserPath(fullPath.subList(0, fullPath.size() - 1), this.repository, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewLambdaFunction.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewLambdaFunction.java index f557a529543..37839cafa17 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewLambdaFunction.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewLambdaFunction.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Paths; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.compiler.Context; @@ -43,7 +44,7 @@ public NewLambdaFunction(FunctionExecutionInterpreted functionExecution, ModelRe } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { CoreInstance genericType = this.repository.newAnonymousCoreInstance(null, processorSupport.package_getByUserPath(M3Paths.GenericType)); Instance.addValueToProperty(genericType, M3Properties.rawType, processorSupport.package_getByUserPath(M3Paths.LambdaFunction), processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewProperty.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewProperty.java index b93067594e1..8edd8bccec2 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewProperty.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/meta/NewProperty.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Paths; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -45,7 +46,7 @@ public NewProperty(FunctionExecutionInterpreted functionExecution, ModelReposito } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String name = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); CoreInstance ownerGenericType = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport); @@ -60,7 +61,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String name = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); CoreInstance ownerGenericType = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport); @@ -61,7 +62,7 @@ public CoreInstance execute(ListIterable params, Stack params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { return ValueSpecificationBootstrap.newStringLiteral(this.repository, IdentityManager.getAuthenticatedUserId(), processorSupport); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/Guid.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/Guid.java index c6e93e94376..a05f01789e6 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/Guid.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/Guid.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.ValueSpecificationBootstrap; @@ -42,7 +43,7 @@ public Guid(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String res = UUID.randomUUID().toString(); return ValueSpecificationBootstrap.newStringLiteral(this.repository, res, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/IsOptionSet.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/IsOptionSet.java index bc15e98fcdc..b2d8ac6e842 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/IsOptionSet.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/runtime/IsOptionSet.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.compiler.Context; @@ -44,7 +45,7 @@ public IsOptionSet(FunctionExecutionInterpreted functionExecution, ModelReposito } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { PureRuntime runtime = functionExecution.getRuntime(); String name = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/ASCII.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/ASCII.java index bc05fad7b90..c8d8585256a 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/ASCII.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/ASCII.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.Instance; import org.finos.legend.pure.m3.navigation.M3Properties; @@ -42,7 +43,7 @@ public ASCII(FunctionExecutionInterpreted functionExecution, ModelRepository rep } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String str = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); return ValueSpecificationBootstrap.newIntegerLiteral(this.repository, str.length() > 0 ? (int) str.charAt(0) : 0, processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Char.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Char.java index 4737d506896..fbdf1b88685 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Char.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Char.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Paths; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.compiler.Context; @@ -45,7 +46,7 @@ public Char(FunctionExecutionInterpreted functionExecution, ModelRepository repo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { Number input = NumericUtilities.toJavaNumber(Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport), processorSupport); return ValueSpecificationBootstrap.wrapValueSpecification(this.repository.newCoreInstance(String.valueOf((char) input.intValue()), processorSupport.package_getByUserPath(M3Paths.String), null), ValueSpecification.isExecutable(params.get(0), processorSupport), processorSupport); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Chunk.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Chunk.java index 8131b2762bd..03220197ef9 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Chunk.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Chunk.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.list.mutable.FastList; import org.finos.legend.pure.m3.navigation.M3Properties; @@ -48,14 +49,14 @@ public Chunk(FunctionExecutionInterpreted functionExecution, ModelRepository rep } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String text = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); int chunkSize = PrimitiveUtilities.getIntegerValue(Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport)).intValue(); if (chunkSize < 1) { - throw new PureExecutionException(functionExpressionToUseInStack.getSourceInformation(), "Invalid chunk size: " + chunkSize); + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), "Invalid chunk size: " + chunkSize, functionExpressionCallStack); } if (text.isEmpty()) diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeBase64.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeBase64.java index 44fd31a4a9c..3f3e6ecd244 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeBase64.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeBase64.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Paths; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.compiler.Context; @@ -45,7 +46,7 @@ public DecodeBase64(FunctionExecutionInterpreted functionExecution, ModelReposit } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String string = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String decodedString = new String(Base64.decodeBase64(string)); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeUrl.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeUrl.java index 213788c3e5d..7cef42e05cc 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeUrl.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/DecodeUrl.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.Instance; import org.finos.legend.pure.m3.navigation.M3Paths; @@ -46,7 +47,7 @@ public DecodeUrl(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String string = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String charset = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeBase64.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeBase64.java index c2119c50d56..bb9f0a34f3d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeBase64.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeBase64.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Paths; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.compiler.Context; @@ -45,7 +46,7 @@ public EncodeBase64(FunctionExecutionInterpreted functionExecution, ModelReposit } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String string = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String encodedString = Base64.encodeBase64URLSafeString(string.getBytes()); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeUrl.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeUrl.java index 4b9b03759df..16fc0c439cd 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeUrl.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/EncodeUrl.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.Instance; import org.finos.legend.pure.m3.navigation.M3Paths; @@ -46,7 +47,7 @@ public EncodeUrl(FunctionExecutionInterpreted functionExecution, ModelRepository } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { String string = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String charset = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/JaroWinklerSimilarity.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/JaroWinklerSimilarity.java index 0356e92cb2f..ede5045d91f 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/JaroWinklerSimilarity.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/JaroWinklerSimilarity.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.Instance; import org.finos.legend.pure.m3.navigation.M3Properties; @@ -42,7 +43,7 @@ public JaroWinklerSimilarity(FunctionExecutionInterpreted functionExecution, Mod } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { final String str1 = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); final String str2 = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/LevenshteinDistance.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/LevenshteinDistance.java index 0cf79f1311b..397c7767d09 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/LevenshteinDistance.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/LevenshteinDistance.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.navigation.Instance; import org.finos.legend.pure.m3.navigation.M3Properties; @@ -42,7 +43,7 @@ public LevenshteinDistance(FunctionExecutionInterpreted functionExecution, Model } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) { final String str1 = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); final String str2 = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Matches.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Matches.java index 8a659b4b620..cea516fea4b 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Matches.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/string/Matches.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -39,7 +40,7 @@ public Matches(FunctionExecutionInterpreted functionExecution, ModelRepository r } @Override - protected boolean executeBoolean(Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, ListIterable params, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport) throws PureExecutionException + protected boolean executeBoolean(Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, ListIterable params, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport) throws PureExecutionException { String string = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); String regexp = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/tracing/TraceSpan.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/tracing/TraceSpan.java index 126cbc47418..77123df7b85 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/tracing/TraceSpan.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/main/java/org/finos/legend/pure/runtime/java/extension/functions/interpreted/natives/tracing/TraceSpan.java @@ -20,6 +20,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunctionCoreInstanceWrapper; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -83,7 +84,7 @@ public TraceSpan(FunctionExecutionInterpreted functionExecution, ModelRepository public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, - VariableContext variableContext, CoreInstance functionExpressionToUseInStack, + VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, @@ -92,7 +93,7 @@ public CoreInstance execute(ListIterable params, { if (Instance.instanceOf(Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport), M3Paths.Nil, processorSupport)) { - throw new PureExecutionException(functionExpressionToUseInStack.getSourceInformation(), "Evaluate can't take an instance of Nil as a function"); + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), "Evaluate can't take an instance of Nil as a function", functionExpressionCallStack); } // add check to disable tracing - use isRegistered() @@ -109,7 +110,7 @@ public CoreInstance execute(ListIterable params, resolvedTypeParameters, resolvedMultiplicityParameters, getParentOrEmptyVariableContext(variableContext), - functionExpressionToUseInStack, + functionExpressionCallStack, profiler, instantiationContext, executionSupport); @@ -119,7 +120,7 @@ public CoreInstance execute(ListIterable params, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, - functionExpressionToUseInStack, + functionExpressionCallStack, profiler, instantiationContext, executionSupport, @@ -131,7 +132,7 @@ public CoreInstance execute(ListIterable params, private CoreInstance executeWithTrace(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, - VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, + VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, CoreInstance functionToApplyTo, String traceName) { @@ -147,7 +148,7 @@ private CoreInstance executeWithTrace(ListIterable param } resolveTagsAndAddToTrace(params, resolvedTypeParameters, resolvedMultiplicityParameters, - variableContext, functionExpressionToUseInStack, profiler, + variableContext, functionExpressionCallStack, profiler, instantiationContext, executionSupport, processorSupport, tagsCritical, span); } @@ -158,7 +159,7 @@ private CoreInstance executeWithTrace(ListIterable param resolvedTypeParameters, resolvedMultiplicityParameters, getParentOrEmptyVariableContext(variableContext), - functionExpressionToUseInStack, + functionExpressionCallStack, profiler, instantiationContext, executionSupport); @@ -175,7 +176,7 @@ private CoreInstance executeWithTrace(ListIterable param private void resolveTagsAndAddToTrace(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, - VariableContext variableContext, CoreInstance functionExpressionToUseInStack, + VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, ProcessorSupport processorSupport, boolean tagsCritical, Span span) @@ -192,7 +193,7 @@ private void resolveTagsAndAddToTrace(ListIterable param Lists.mutable.empty(), resolvedTypeParameters, resolvedMultiplicityParameters, getParentOrEmptyVariableContext(variableContext), - functionExpressionToUseInStack, profiler, instantiationContext, + functionExpressionCallStack, profiler, instantiationContext, executionSupport); MutableMap tagsMap = ((MapCoreInstance) Instance.getValueForMetaPropertyToManyResolved(coreInstance, M3Properties.values, processorSupport).getFirst()).getMap(); addTags(span, tagsMap); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertContains.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertContains.java index 443baacd6f5..08b415e2a1e 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertContains.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertContains.java @@ -31,7 +31,7 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("[1, 2, 5, 2, 'a', true, %2014-02-01, 'c'] does not contain false", 3, 9, "assertContains([1, 2, 5, 2, 'a', true, %2014-02-01, 'c'], false)"); + assertExpressionRaisesPureException("[1, 2, 5, 2, 'a', true, %2014-02-01, 'c'] does not contain false", 37, 5, "assertContains([1, 2, 5, 2, 'a', true, %2014-02-01, 'c'], false)"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEmpty.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEmpty.java index 2e9f162af99..d7136da8367 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEmpty.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEmpty.java @@ -31,7 +31,7 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("[1, 2] is not empty", 3, 9, "assertEmpty([1, 2])"); + assertExpressionRaisesPureException("[1, 2] is not empty", 21, 5, "assertEmpty([1, 2])"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEqWithinTolerance.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEqWithinTolerance.java index 9901d86ecc6..067a9d8567a 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEqWithinTolerance.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEqWithinTolerance.java @@ -31,9 +31,9 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("\nexpected: 1\nactual: 0", 3, 9, "assertEqWithinTolerance(1, 0, 0)"); - assertExpressionRaisesPureException("\nexpected: 2.718271828459045\nactual: 2.718281828459045", 3, 9, "assertEqWithinTolerance(2.718271828459045, 2.718281828459045, 0.000000001)"); - assertExpressionRaisesPureException("\nexpected: 2.718281828459045\nactual: 2.7182818284590455", 3, 9, "assertEqWithinTolerance(2.718281828459045, 2.7182818284590455, 0.0000000000000001)"); + assertExpressionRaisesPureException("\nexpected: 1\nactual: 0", 21, 5, "assertEqWithinTolerance(1, 0, 0)"); + assertExpressionRaisesPureException("\nexpected: 2.718271828459045\nactual: 2.718281828459045", 21, 5, "assertEqWithinTolerance(2.718271828459045, 2.718281828459045, 0.000000001)"); + assertExpressionRaisesPureException("\nexpected: 2.718281828459045\nactual: 2.7182818284590455", 21, 5, "assertEqWithinTolerance(2.718281828459045, 2.7182818284590455, 0.0000000000000001)"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEquals.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEquals.java index 86ec88f3488..7328f509f5a 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEquals.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertEquals.java @@ -31,15 +31,15 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("\nexpected: 1\nactual: 2", 3, 9, "assertEquals(1, 2)"); + assertExpressionRaisesPureException("\nexpected: 1\nactual: 2", 21, 5, "assertEquals(1, 2)"); } @Test public void testFailureWithCollections() { - assertExpressionRaisesPureException("\nexpected: [1, 3, 2]\nactual: [2, 4, 1, 5]", 3, 9, "assertEquals([1, 3, 2], [2, 4, 1, 5])"); - assertExpressionRaisesPureException("\nexpected: [1, 2]\nactual: [2, 1]", 3, 9, "assertEquals([1, 2], [2, 1])"); - assertExpressionRaisesPureException("\nexpected: ['aaa', 2]\nactual: [2, 'aaa']", 3, 9, "assertEquals(['aaa', 2], [2, 'aaa'])"); + assertExpressionRaisesPureException("\nexpected: [1, 3, 2]\nactual: [2, 4, 1, 5]", 21, 5, "assertEquals([1, 3, 2], [2, 4, 1, 5])"); + assertExpressionRaisesPureException("\nexpected: [1, 2]\nactual: [2, 1]", 21, 5, "assertEquals([1, 2], [2, 1])"); + assertExpressionRaisesPureException("\nexpected: ['aaa', 2]\nactual: [2, 'aaa']", 21, 5, "assertEquals(['aaa', 2], [2, 'aaa'])"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertFalse.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertFalse.java index fb2a3a0d72c..89d62e5dfc8 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertFalse.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertFalse.java @@ -31,29 +31,29 @@ public static void setUp() @Test public void testFailWithoutMessage() { - assertExpressionRaisesPureException("Assert failed", 3, 9, "assertFalse(true)"); - assertExpressionRaisesPureException("Assert failed", 3, 9, "assertFalse(2 == 2)"); + assertExpressionRaisesPureException("Assert failed", 26, 5, "assertFalse(true)"); + assertExpressionRaisesPureException("Assert failed", 26, 5, "assertFalse(2 == 2)"); } @Test public void testFailWithMessageString() { - assertExpressionRaisesPureException("Test message", 3, 9, "assertFalse(true, 'Test message')"); - assertExpressionRaisesPureException("Test message", 3, 9, "assertFalse(2 == 2, 'Test message')"); + assertExpressionRaisesPureException("Test message", 26, 5, "assertFalse(true, 'Test message')"); + assertExpressionRaisesPureException("Test message", 26, 5, "assertFalse(2 == 2, 'Test message')"); } @Test public void testFailWithFormattedMessage() { - assertExpressionRaisesPureException("Test message: 5", 3, 9, "assertFalse(true, 'Test message: %d', 2 + 3)"); - assertExpressionRaisesPureException("Test message: 5", 3, 9, "assertFalse(2 == 2, 'Test message: %d', 2 + 3)"); + assertExpressionRaisesPureException("Test message: 5", 21, 5, "assertFalse(true, 'Test message: %d', 2 + 3)"); + assertExpressionRaisesPureException("Test message: 5", 21, 5, "assertFalse(2 == 2, 'Test message: %d', 2 + 3)"); } @Test public void testFailWithMessageFunction() { - assertExpressionRaisesPureException("Test message: 5", 3, 9, "assertFalse(true, |format('Test message: %d', 2 + 3))"); - assertExpressionRaisesPureException("Test message: 5", 3, 9, "assertFalse(2 == 2, |format('Test message: %d', 2 + 3))"); + assertExpressionRaisesPureException("Test message: 5", 29, 5, "assertFalse(true, |format('Test message: %d', 2 + 3))"); + assertExpressionRaisesPureException("Test message: 5", 29, 5, "assertFalse(2 == 2, |format('Test message: %d', 2 + 3))"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertInstanceOf.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertInstanceOf.java index 0b65c45b608..37a18526cc5 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertInstanceOf.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertInstanceOf.java @@ -31,7 +31,7 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("expected 3 to be an instance of Boolean, actual: Integer", 3, 9, "assertInstanceOf(3, Boolean)"); + assertExpressionRaisesPureException("expected 3 to be an instance of Boolean, actual: Integer", 34, 5, "assertInstanceOf(3, Boolean)"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotContains.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotContains.java index 965ebdbd476..584ee7edff3 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotContains.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotContains.java @@ -31,7 +31,7 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("[1, 2, 5, 2, 'a', true, %2014-02-01, 'c'] should not contain true", 3, 9, "assertNotContains([1, 2, 5, 2, 'a', true, %2014-02-01, 'c'], true)"); + assertExpressionRaisesPureException("[1, 2, 5, 2, 'a', true, %2014-02-01, 'c'] should not contain true", 36, 5, "assertNotContains([1, 2, 5, 2, 'a', true, %2014-02-01, 'c'], true)"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEmpty.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEmpty.java index ce7290c12a4..0d0c884ee48 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEmpty.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEmpty.java @@ -31,7 +31,7 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("Expected non-empty collection", 3, 9, "assertNotEmpty([1, 2, 3]->filter(x | $x == 5))"); + assertExpressionRaisesPureException("Expected non-empty collection", 26, 5, "assertNotEmpty([1, 2, 3]->filter(x | $x == 5))"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEquals.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEquals.java index e5a39e0194a..b943ea42ebd 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEquals.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotEquals.java @@ -33,15 +33,15 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("1 should not equal 1", 3, 9, "assertNotEquals(1, 1)"); + assertExpressionRaisesPureException("1 should not equal 1", 21, 5, "assertNotEquals(1, 1)"); } @Test public void testFailureWithCollections() { - assertExpressionRaisesPureException("[1, 2] should not equal [1, 2]", 3, 9, "assertNotEquals([1, 2], [1, 2])"); - assertExpressionRaisesPureException("['aaa', 'bb'] should not equal ['aaa', 'bb']", 3, 9, "assertNotEquals(['aaa', 'bb'], ['aaa', 'bb'])"); - assertExpressionRaisesPureException("['aaa', 2] should not equal ['aaa', 2]", 3, 9, "assertNotEquals(['aaa', 2], ['aaa', 2])"); + assertExpressionRaisesPureException("[1, 2] should not equal [1, 2]", 34, 5, "assertNotEquals([1, 2], [1, 2])"); + assertExpressionRaisesPureException("['aaa', 'bb'] should not equal ['aaa', 'bb']", 34, 5, "assertNotEquals(['aaa', 'bb'], ['aaa', 'bb'])"); + assertExpressionRaisesPureException("['aaa', 2] should not equal ['aaa', 2]", 34, 5, "assertNotEquals(['aaa', 2], ['aaa', 2])"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotSize.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotSize.java index 2b492088fbd..63f3ba636b6 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotSize.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertNotSize.java @@ -31,7 +31,7 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("size should not equal: 2", 3, 9, "assertNotSize([1, 2], 2)"); + assertExpressionRaisesPureException("size should not equal: 2", 32, 5, "assertNotSize([1, 2], 2)"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSameElements.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSameElements.java index 3005b7a229b..27df6ea5227 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSameElements.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSameElements.java @@ -31,8 +31,8 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("\nexpected: [1, 2, 3]\nactual: [1, 2, 4, 5]", 3, 9, "assertSameElements([1, 3, 2], [2, 4, 1, 5])"); - assertExpressionRaisesPureException("\nexpected: [1, 3, '2']\nactual: [1, 4, 5, '2']", 3, 9, "assertSameElements([1, 3, '2'], ['2', 4, 1, 5])"); + assertExpressionRaisesPureException("\nexpected: [1, 2, 3]\nactual: [1, 2, 4, 5]", 31, 5, "assertSameElements([1, 3, 2], [2, 4, 1, 5])"); + assertExpressionRaisesPureException("\nexpected: [1, 3, '2']\nactual: [1, 4, 5, '2']", 31, 5, "assertSameElements([1, 3, '2'], ['2', 4, 1, 5])"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSize.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSize.java index 336e2dfe6b3..02e7df3a2b7 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSize.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestAssertSize.java @@ -31,7 +31,7 @@ public static void setUp() @Test public void testFailure() { - assertExpressionRaisesPureException("expected size: 3, actual size: 2", 3, 9, "assertSize([1, 2], 3)"); + assertExpressionRaisesPureException("expected size: 3, actual size: 2", 21, 5, "assertSize([1, 2], 3)"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestFail.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestFail.java index 9217af346fa..a2cb6a743b5 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestFail.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/asserts/TestFail.java @@ -31,13 +31,13 @@ public static void setUp() @Test public void testFail() { - assertExpressionRaisesPureException("Assert failed", 3, 9, "fail()"); + assertExpressionRaisesPureException("Assert failed", 26, 5, "fail()"); } @Test public void testFailWithMessage() { - assertExpressionRaisesPureException("Error Here", 3, 9, "fail('Error Here')"); + assertExpressionRaisesPureException("Error Here", 26, 5, "fail('Error Here')"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/multiplicity/TestGetUpperBound.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/multiplicity/TestGetUpperBound.java index 6abbc591fcc..f7b4bff3568 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/multiplicity/TestGetUpperBound.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/multiplicity/TestGetUpperBound.java @@ -31,13 +31,13 @@ public static void setUp() @Test public void testGetUpperBoundZeroManyError() { - assertExpressionRaisesPureException("Cannot cast a collection of size 0 to multiplicity [1]", 3, 19, "ZeroMany->getUpperBound()"); + assertExpressionRaisesPureException("Cannot cast a collection of size 0 to multiplicity [1]", 19, 46, "ZeroMany->getUpperBound()"); } @Test public void testGetUpperBoundOneManyError() { - assertExpressionRaisesPureException("Cannot cast a collection of size 0 to multiplicity [1]", 3, 18, "OneMany->getUpperBound()"); + assertExpressionRaisesPureException("Cannot cast a collection of size 0 to multiplicity [1]", 19, 46, "OneMany->getUpperBound()"); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/tools/TestProfile.java b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/tools/TestProfile.java index 900574a5a66..ab7d0e2e3cc 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/tools/TestProfile.java +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-interpreted-functions-unclassified/src/test/java/org/finos/legend/pure/runtime/java/interpreted/function/base/tools/TestProfile.java @@ -93,7 +93,8 @@ public void testPathToElementProfile() " name(Property):\n" + " [>1] K instance String\n" + " package(Property):\n" + - " [>1] C instance Package", functionExecution.getConsole().getLine(1)); + " [>1] C instance Package\n" + + " typeVariables(Property):", functionExecution.getConsole().getLine(1)); } protected static FunctionExecution getFunctionExecution() diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-shared-functions-unclassified/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-shared-functions-unclassified/pom.xml index 5270e3ac1de..43b16837712 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-shared-functions-unclassified/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/legend-engine-pure-runtime-java-extension-shared-functions-unclassified/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-code-functions-unclassified - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-shared-functions-unclassified diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/pom.xml index becb253dce5..7c49a5c0b78 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-functions-unclassified/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-diagram-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-diagram-java/pom.xml index c6657d88efa..8a1dbf86e4d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-diagram-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-diagram-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-dsl-diagram-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-graph-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-graph-java/pom.xml index 057c99c687d..a5816a7596d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-graph-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-graph-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-dsl-graph-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-mapping-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-mapping-java/pom.xml index 81bdb07cc75..ecdc2629ef5 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-mapping-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-mapping-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-dsl-mapping-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-path-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-path-java/pom.xml index 3f3cb8768dc..92cdbfc35dc 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-path-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-path-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-dsl-path-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-store-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-store-java/pom.xml index 1faed739904..8f34ed9ef35 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-store-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-store-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-dsl-store-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-tds-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-tds-java/pom.xml index 65e6c477847..4e80c720109 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-tds-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-dsl-tds-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-dsl-tds-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-java/pom.xml index e243715791a..08dc4410288 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-store-relational-java/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-store-relational-java/pom.xml index b9fbebf0e61..dd6e13be95c 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-store-relational-java/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/legend-engine-pure-platform-store-relational-java/pom.xml @@ -22,7 +22,7 @@ org.finos.legend.engine legend-engine-pure-platform-modular-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-platform-store-relational-java diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/pom.xml b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/pom.xml index 6e6e138a660..7ce19861c87 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-platform-modular-generation/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-pure/pom.xml b/legend-engine-core/legend-engine-core-pure/pom.xml index c5610e56173..421479c1f10 100644 --- a/legend-engine-core/legend-engine-core-pure/pom.xml +++ b/legend-engine-core/legend-engine-core-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-query-pure-http-api/pom.xml b/legend-engine-core/legend-engine-core-query-pure-http-api/pom.xml index 521d6e3d3a4..5aa21f1af5b 100644 --- a/legend-engine-core/legend-engine-core-query-pure-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-query-pure-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-core-query-pure-http-api diff --git a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-core/pom.xml b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-core/pom.xml index d0670472848..add6d09a8c3 100644 --- a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-core/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-core/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-shared - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-shared-core @@ -178,14 +178,10 @@ commons-io test - - org.finos.legend.engine - legend-engine-identity-core - org.finos.legend.engine legend-engine-xt-identity-pac4j - \ No newline at end of file + diff --git a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-extensions/pom.xml b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-extensions/pom.xml index e098be01f9c..929bc8b861a 100644 --- a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-extensions/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-extensions/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-shared - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-shared-extensions diff --git a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-javaCompiler/pom.xml b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-javaCompiler/pom.xml index 7f46b5fd087..6ff733b465a 100644 --- a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-javaCompiler/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-javaCompiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-shared - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-shared-javaCompiler diff --git a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-structures/pom.xml b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-structures/pom.xml index f56a2b30e69..a4db4cbaaa8 100644 --- a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-structures/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-structures/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-shared - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-shared-structures diff --git a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-aws/pom.xml b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-aws/pom.xml index ba41cabde53..530364e8d74 100644 --- a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-aws/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-aws/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-shared-vault - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-shared-vault-aws diff --git a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-core/pom.xml b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-core/pom.xml index 3c2d440cad2..a522a69f1da 100644 --- a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-core/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/legend-engine-shared-vault-core/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-shared-vault - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-shared-vault-core diff --git a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/pom.xml b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/pom.xml index 13089808058..94350a25549 100644 --- a/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/legend-engine-shared-vault/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-shared - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-shared/pom.xml b/legend-engine-core/legend-engine-core-shared/pom.xml index 3194a7c7520..ddcf06982c4 100644 --- a/legend-engine-core/legend-engine-core-shared/pom.xml +++ b/legend-engine-core/legend-engine-core-shared/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation-api/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation-api/pom.xml index 903e0bccfea..facf562be75 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation-api/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation-api/pom.xml @@ -16,7 +16,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation/pom.xml index b6b3b377d93..6ef221a2d76 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-execution-test-data-generation/pom.xml @@ -16,7 +16,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-test-framework/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-test-framework/pom.xml index 69abbca4a11..99e5480113e 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-test-framework/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-test-framework/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-test-framework diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-function/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-function/pom.xml index ab36cb8fe70..d805bbc2c43 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-function/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-function/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-mapping/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-mapping/pom.xml index 834c807ac3a..e48b7d5791c 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-mapping/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-mapping/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-shared/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-shared/pom.xml index 5ddd016ab5f..49e8668afab 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-shared/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-test-runner-shared/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-test-runner-shared diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-test-server-shared/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-test-server-shared/pom.xml index 23623358ec1..1f3a06dfc5e 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-test-server-shared/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-test-server-shared/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-test-server-shared diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-testable-http-api/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-testable-http-api/pom.xml index e49e41ff9e9..23fb8f479ad 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-testable-http-api/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-testable-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-testable-http-api diff --git a/legend-engine-core/legend-engine-core-testable/legend-engine-testable/pom.xml b/legend-engine-core/legend-engine-core-testable/legend-engine-testable/pom.xml index b07fe17c5cb..f251a576774 100644 --- a/legend-engine-core/legend-engine-core-testable/legend-engine-testable/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/legend-engine-testable/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-core-testable - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-testable diff --git a/legend-engine-core/legend-engine-core-testable/pom.xml b/legend-engine-core/legend-engine-core-testable/pom.xml index 3ffbd08b837..b3dfd29dbe3 100644 --- a/legend-engine-core/legend-engine-core-testable/pom.xml +++ b/legend-engine-core/legend-engine-core-testable/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-core - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-core/pom.xml b/legend-engine-core/pom.xml index 3beae4d73ef..92c90a5dd04 100644 --- a/legend-engine-core/pom.xml +++ b/legend-engine-core/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md index ff252271d2c..c13a8aa6e31 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md @@ -8,7 +8,7 @@ Pure IDE Light is a development environment for Pure, the language underlying th From the root of legend-engine, run the following to launch the Pure IDE Light server. ``` -mvn -pl legend-engine-pure-ide-light exec:java -Dexec.mainClass="org.finos.legend.engine.ide.PureIDELight" -Dexec.args="server ./legend-engine-pure-ide-light/src/main/resources/ideLightConfig.json" +mvn -pl legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server exec:java -Dexec.mainClass="org.finos.legend.engine.ide.PureIDELight" -Dexec.args="server ./legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/resources/ideLightConfig.json" ``` Then navigate to http://127.0.0.1/ide diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml index 831e9f185f2..926ded244f2 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-ide - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -260,6 +260,16 @@ org.finos.legend.engine legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler + runtime + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler + runtime + org.finos.legend.engine @@ -278,6 +288,16 @@ runtime ${project.version} + + org.finos.legend.engine + legend-engine-xt-relationalStore-SDT-pure + runtime + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser + runtime + diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/PureIDELight.java b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/PureIDELight.java index a224abf8bf6..94bc87f16f0 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/PureIDELight.java +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/PureIDELight.java @@ -29,7 +29,7 @@ public class PureIDELight extends PureIDEServer public static void main(String[] args) throws Exception { System.setProperty("legend.test.h2.port", "1975"); - System.setProperty("user.timezone","GMT"); + System.setProperty("user.timezone", "GMT"); new PureIDELight().run(args.length == 0 ? new String[]{"server", "legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/resources/ideLightConfig.json"} : args); } @@ -99,6 +99,7 @@ protected MutableList buildRepositories(SourceLocationCon .with(this.buildCore("legend-engine-xts-haskell/legend-engine-xt-haskell-pure", "external-language-haskell")) .with(this.buildCore("legend-engine-xts-daml/legend-engine-xt-daml-pure", "external-language-daml")) .with(this.buildCore("legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure", "pure-changetoken")) + .with(this.buildCore("legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure", "pure-changetoken-test")) .with(this.buildCore("legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure", "analytics-mapping")) .with(this.buildCore("legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-pure", "analytics-class")) .with(this.buildCore("legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-pure", "analytics-binding")) @@ -108,7 +109,7 @@ protected MutableList buildRepositories(SourceLocationCon .with(this.buildCore("legend-engine-xts-java/legend-engine-xt-javaGeneration-pure", "external-language-java")) .with(this.buildCore("legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure", "external-language-java-feature-based-generation")) .with(this.buildCore("legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure", "java-platform-binding")) - .with(this.buildCore("legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure", "external-store-relational-postgres-sql-model")) + .with(this.buildCore("legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure", "external-store-relational-postgres-sql-model")) .with(this.buildCore("legend-engine-xts-sql/legend-engine-xt-sql-pure", "external-query-sql")) .with(this.buildCore("legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-pure-specification-metamodel", "elasticsearch_specification_metamodel")) .with(this.buildCore("legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test", "elasticsearch_execution_test")) @@ -123,7 +124,8 @@ protected MutableList buildRepositories(SourceLocationCon .with(this.buildCore("legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlPlanning-pure", "external-store-relational-sql-planning")) .with(this.buildCore("legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure", "external-store-relational-sql-dialect-translation")) .with(this.buildCore("legend-engine-core/legend-engine-core-testable/legend-engine-executable-test-pure", "executable-test-wrapper")) - + .with(this.buildCore("legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure", "external-store-relational-sdt")) + .with(this.buildCore("legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure", "external-store-relational-sql-dialect-translation-duckdb")) ; } diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/concept/Concept.java b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/concept/Concept.java index a61df113675..64c391fe083 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/concept/Concept.java +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/concept/Concept.java @@ -16,12 +16,13 @@ import io.swagger.annotations.Api; import org.finos.legend.engine.ide.session.PureSession; -import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedPropertyInstance; import org.finos.legend.pure.m3.navigation.Instance; import org.finos.legend.pure.m3.navigation.M3Paths; import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement; +import org.finos.legend.pure.m3.navigation.function.Function; +import org.finos.legend.pure.m3.pct.shared.PCTTools; import org.finos.legend.pure.m3.serialization.runtime.PureRuntime; import org.finos.legend.pure.m3.serialization.runtime.Source; import org.finos.legend.pure.m4.coreinstance.CoreInstance; @@ -77,24 +78,32 @@ public Response getConceptInfo(@Context HttpServletRequest request, @Context Htt CoreInstance found = src.navigate(Integer.parseInt(line), Integer.parseInt(column), session.getPureRuntime().getProcessorSupport()); if (found != null) { + String doc = PCTTools.getDoc(found, pureRuntime.getProcessorSupport()); if (Instance.instanceOf(found, M3Paths.AbstractProperty, session.getPureRuntime().getProcessorSupport())) { String path = PackageableElement.getUserPathForPackageableElement(found); CoreInstance owner = Instance.getValueForMetaPropertyToOneResolved(found, M3Properties.owner, session.getPureRuntime().getProcessorSupport()); String ownerPath = PackageableElement.getUserPathForPackageableElement(owner); - outputStream.write(("{\"path\":\"" + path + "\",\"pureName\":\"" + found.getValueForMetaPropertyToOne(M3Properties.name).getName() + "\",\"owner\":\"" + ownerPath + "\",\"pureType\":\"" + (found instanceof QualifiedPropertyInstance ? "QualifiedProperty" : "Property") + "\"}").getBytes()); + outputStream.write(("{\"path\":\"" + path + "\",\"pureName\":\"" + found.getValueForMetaPropertyToOne(M3Properties.name).getName() + "\",\"owner\":\"" + ownerPath + "\",\"pureType\":\"" + (found instanceof QualifiedPropertyInstance ? "QualifiedProperty" : "Property") + "\",\"doc\":" + (doc != null ? ("\"" + doc + "\"") : null) + "}").getBytes()); } else if (Instance.instanceOf(found, M3Paths.Enum, session.getPureRuntime().getProcessorSupport())) { String path = PackageableElement.getUserPathForPackageableElement(found); CoreInstance owner = found.getClassifier(); String ownerPath = PackageableElement.getUserPathForPackageableElement(owner); - outputStream.write(("{\"path\":\"" + path + "\",\"pureName\":\"" + found.getName() + "\",\"owner\":\"" + ownerPath + "\",\"pureType\":\"Enum\"}").getBytes()); + outputStream.write(("{\"path\":\"" + path + "\",\"pureName\":\"" + found.getName() + "\",\"owner\":\"" + ownerPath + "\",\"pureType\":\"Enum\",\"doc\":" + (doc != null ? ("\"" + doc + "\"") : null) + "}").getBytes()); + } + else if (Instance.instanceOf(found, M3Paths.ConcreteFunctionDefinition, session.getPureRuntime().getProcessorSupport()) || Instance.instanceOf(found, M3Paths.NativeFunction, session.getPureRuntime().getProcessorSupport())) + { + String path = PackageableElement.getUserPathForPackageableElement(found); + String grammarDoc = PCTTools.getGrammarDoc(found, pureRuntime.getProcessorSupport()); + String grammarChars = PCTTools.getGrammarCharacters(found, pureRuntime.getProcessorSupport()); + outputStream.write(("{\"path\":\"" + path + "\",\"pureName\":\"" + found.getValueForMetaPropertyToOne(M3Properties.functionName).getName() + "\",\"pureType\":\"" + found.getValueForMetaPropertyToOne(M3Properties.classifierGenericType).getValueForMetaPropertyToOne(M3Properties.rawType).getName() + "\",\"test\":" + (PCTTools.isPCTTest(found, pureRuntime.getProcessorSupport()) || PCTTools.isTest(found, pureRuntime.getProcessorSupport())) + ",\"pct\":" + PCTTools.isPCTTest(found, pureRuntime.getProcessorSupport()) + ",\"doc\":" + (doc != null ? ("\"" + doc + "\"") : null) + ",\"grammarDoc\":" + (grammarDoc != null ? ("\"" + grammarDoc + "\"") : null) + ",\"grammarChars\":" + (grammarChars != null ? ("\"" + grammarChars + "\"") : null) + ",\"signature\":\"" + Function.prettyPrint(found, pureRuntime.getProcessorSupport()) + "\"}").getBytes()); } else { String path = PackageableElement.getUserPathForPackageableElement(found); - outputStream.write(("{\"path\":\"" + path + "\",\"pureName\":\"" + (found instanceof ConcreteFunctionDefinition ? found.getValueForMetaPropertyToOne(M3Properties.functionName).getName() : found.getName()) + "\",\"pureType\":\"" + found.getValueForMetaPropertyToOne(M3Properties.classifierGenericType).getValueForMetaPropertyToOne(M3Properties.rawType).getName() + "\"}").getBytes()); + outputStream.write(("{\"path\":\"" + path + "\",\"pureName\":\"" + found.getName() + "\",\"pureType\":\"" + found.getValueForMetaPropertyToOne(M3Properties.classifierGenericType).getValueForMetaPropertyToOne(M3Properties.rawType).getName() + "\",\"doc\":" + (doc != null ? ("\"" + doc + "\"") : null) + "}").getBytes()); } } else diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/function/Execute.java b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/function/Execute.java index c44baf83220..fb32f76825e 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/function/Execute.java +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/function/Execute.java @@ -15,6 +15,7 @@ package org.finos.legend.engine.ide.api.execution.function; import io.swagger.annotations.Api; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.impl.utility.MapIterate; import org.finos.legend.engine.ide.api.execution.function.manager.ContentType; import org.finos.legend.engine.ide.api.execution.function.manager.ExecutionManager; @@ -33,6 +34,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import java.util.Map; +import java.util.Stack; @Api(tags = "Execute") @Path("/") @@ -56,7 +58,7 @@ public Response execute(@Context HttpServletRequest request, @Context HttpServle FunctionExecution functionExecution = this.pureSession.getFunctionExecution(); if (null == functionExecution || !functionExecution.isFullyInitializedForExecution()) { - throw new PureExecutionException("System not initialized. Make sure that your pure code has compiled successfully in the IDE."); + throw new PureExecutionException("System not initialized. Make sure that your pure code has compiled successfully in the IDE.", Stacks.mutable.empty()); } ExecutionManager executionManager = new ExecutionManager(functionExecution); diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/test/TestRun.java b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/test/TestRun.java index accf2a319a9..c10d6f76681 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/test/TestRun.java +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/execution/test/TestRun.java @@ -36,6 +36,7 @@ import org.finos.legend.pure.m3.navigation.M3Properties; import org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement; import org.finos.legend.pure.m3.navigation.ProcessorSupport; +import org.finos.legend.pure.m3.pct.shared.PCTTools; import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.CodeStorageNode; import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.composite.CompositeCodeStorage; import org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.vcs.MutableVersionControlledCodeStorage; @@ -71,10 +72,22 @@ public void run(PureSession pureSession, JSONObject extraParams, JSONArray modif String path = getPath(extraParams); String[] filterPaths = getFilterPaths(extraParams); boolean relevantTestsOnly = getRelevantTestsOnly(extraParams); + String pctAdapter = (String) extraParams.get("pctAdapter"); Predicate filterPredicate = getFilterPredicate(runtime, relevantTestsOnly); + if (pctAdapter != null) + { + filterPredicate = Predicates.and(filterPredicate, new Predicate() + { + @Override + public boolean accept(CoreInstance test) + { + return PCTTools.isPCTTest(test, runtime.getProcessorSupport()); + } + }); + } TestCollection collection = getTestCollection(pureSession, path, filterPaths, filterPredicate); - TestRunner runner = pureSession.newTestRunner(newId, collection); + TestRunner runner = pureSession.newTestRunner(newId, collection, pctAdapter); this.executorService.execute(runner); @@ -98,6 +111,7 @@ public void run(PureSession pureSession, JSONObject extraParams, JSONArray modif outputStream.write((",\"path\":\"" + path + "\"").getBytes()); outputStream.write((",\"filterPaths\":" + (filterPaths.length == 0 ? "[]" : ArrayIterate.makeString(filterPaths, "[\"", "\",\"", "\"]"))).getBytes()); outputStream.write((",\"relevantTestsOnly\":" + relevantTestsOnly).getBytes()); + outputStream.write((",\"pctAdapter\":\"" + pctAdapter + "\"").getBytes()); outputStream.write(",\"count\":".getBytes()); outputStream.write(Integer.toString(tests.size()).getBytes()); outputStream.write(",\"tests\":".getBytes()); @@ -116,13 +130,13 @@ public String valueOf(TestNode testNode) private String getPath(JSONObject extraParams) { - String path = (String)extraParams.get("path"); + String path = (String) extraParams.get("path"); return StringIterate.isEmpty(path) ? "::" : path; } private String[] getFilterPaths(JSONObject extraParams) { - JSONArray filterPaths = (JSONArray)extraParams.get("filterPaths"); + JSONArray filterPaths = (JSONArray) extraParams.get("filterPaths"); if (filterPaths != null) { String[] paths = new String[filterPaths.size()]; @@ -134,7 +148,7 @@ private String[] getFilterPaths(JSONObject extraParams) private boolean getRelevantTestsOnly(JSONObject extraParams) { - Boolean relevantTestsOnly = (Boolean)extraParams.get("relevantTestsOnly"); + Boolean relevantTestsOnly = (Boolean) extraParams.get("relevantTestsOnly"); return (relevantTestsOnly == null) ? false : relevantTestsOnly; } @@ -142,10 +156,10 @@ private Predicate getFilterPredicate(PureRuntime runtime, { if (!relevantTestsOnly) { - return null; + return Predicates.alwaysTrue(); } - final MutableVersionControlledCodeStorage codeStorage = (MutableVersionControlledCodeStorage)runtime.getCodeStorage(); + final MutableVersionControlledCodeStorage codeStorage = (MutableVersionControlledCodeStorage) runtime.getCodeStorage(); RichIterable modifiedUserFiles = codeStorage.getModifiedUserFiles(); if (modifiedUserFiles.isEmpty()) { diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/find/FindInSources.java b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/find/FindInSources.java index 476a0e7b913..e43c0490d11 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/find/FindInSources.java +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/api/find/FindInSources.java @@ -130,13 +130,13 @@ private int writeResultsJSON(OutputStream stream, RichIterable limit) + if (count >= limit) { break; } } stream.write("]}".getBytes()); - if (count > limit) + if (count >= limit) { break; } diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/helpers/response/ExceptionTranslation.java b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/helpers/response/ExceptionTranslation.java index 513230b8a30..a1e4c304fe6 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/helpers/response/ExceptionTranslation.java +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/helpers/response/ExceptionTranslation.java @@ -25,6 +25,7 @@ import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.tuple.Tuples; import org.finos.legend.engine.ide.session.PureSession; +import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.exception.PureUnmatchedFunctionException; import org.finos.legend.pure.m3.exception.PureUnresolvedIdentifierException; import org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement; @@ -230,7 +231,15 @@ else if ((e instanceof PureParserException || e instanceof PureCompilationExcept response.appendText(pureResponseStr); } - if (e.hasPureStackTrace()) + if (e instanceof PureExecutionException) + { + response.appendText(original.getMessage()); + response.appendText("\n"); + StringBuffer buffer = new StringBuffer(); + ((PureExecutionException) e).printPureStackTrace(buffer, "", session.getFunctionExecution().getProcessorSupport()); + response.appendText(buffer.toString()); + } + else if (e.hasPureStackTrace()) { response.appendText(original.getMessage() + "\n" + e.getPureStackTrace(" ")); } diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/session/PureSession.java b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/session/PureSession.java index d84b6253553..4fe72148b92 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/session/PureSession.java +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/java/org/finos/legend/engine/ide/session/PureSession.java @@ -140,9 +140,9 @@ public void setPureRuntimeOption(String optionName, boolean value) this.pureRuntimeOptions.put(optionName, value); } - public TestRunner newTestRunner(int testRunId, TestCollection collection) + public TestRunner newTestRunner(int testRunId, TestCollection collection, String pctAdapter) { - TestRunnerWrapper testRunnerWrapper = new TestRunnerWrapper(collection, this.getPureRuntime().executedTestTracker); + TestRunnerWrapper testRunnerWrapper = new TestRunnerWrapper(collection, this.getPureRuntime().executedTestTracker, pctAdapter); this.testRunnersById.put(testRunId, testRunnerWrapper); return testRunnerWrapper.testRunner; } @@ -328,9 +328,9 @@ private class TestRunnerWrapper private TestRunner testRunner; private final CallBack callBack; - private TestRunnerWrapper(TestCollection collection, CallBack callBack, final ExecutedTestTracker executedTestTracker) + private TestRunnerWrapper(TestCollection collection, CallBack callBack, final ExecutedTestTracker executedTestTracker, String pctAdapter) { - this.testRunner = new TestRunner(collection, false, PureSession.this.getFunctionExecution(), callBack) + this.testRunner = new TestRunner(collection, false, PureSession.this.getFunctionExecution(), callBack, pctAdapter) { @Override public void run() @@ -346,9 +346,9 @@ public void run() this.callBack = callBack; } - private TestRunnerWrapper(TestCollection collection, ExecutedTestTracker executedTestTracker) + private TestRunnerWrapper(TestCollection collection, ExecutedTestTracker executedTestTracker, String pctAdapter) { - this(collection, new CallBack(), executedTestTracker); + this(collection, new CallBack(), executedTestTracker, pctAdapter); } void stopAndClear() diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-metadata-pure/pom.xml b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-metadata-pure/pom.xml index 4ae4625ee01..3c1031e02bd 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-metadata-pure/pom.xml +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-metadata-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-ide - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/pom.xml b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/pom.xml index 58b6034ef83..8762b812ee1 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/pom.xml +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-ide - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/src/main/resources/pure_ide/concepts.pure b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/src/main/resources/pure_ide/concepts.pure index b194a1c5e13..ecdbd8f57c7 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/src/main/resources/pure_ide/concepts.pure +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/src/main/resources/pure_ide/concepts.pure @@ -158,7 +158,7 @@ function <> meta::pure::ide::display_ide(elem:Any[1]):String[1] |'"/ide/pure/icons/play.png"', |'"/ide/pure/icons/modelElements/function.png"' ); - '{"li_attr":' + display_ide_attr($f) + ', "id":"'+$p->buildKey()+ '","text":"' + printFunctionSignature($f) + '", "icon":'+$icon+'}';, + '{"li_attr":' + display_ide_attr($f) + ', "id":"'+$p->buildKey()+ '","text":"' + printFunctionSignature($f) + '", "icon":'+$icon+', "test":'+ toString(meta::pure::ide::testing::isTest($f)) + ', "pct":' + toString(meta::pure::ide::testing::isPCT($f)) + '}';, f:NativeFunction[1] | '{"li_attr":' + display_ide_attr($f) + ', "id":"'+$p->buildKey()+ '","text":"' + printFunctionSignature($f) + '", "icon":"/ide/pure/icons/modelElements/function_parenthesis.png"}', e:Enumeration[1] | '{"li_attr":' + display_ide_attr($e) + ', "id":"'+$p->buildKey()+ '","text":"' + $e->id() + '", "icon":"/ide/pure/icons/modelElements/enumeration.gif"}', p:PrimitiveType[1] | '{"li_attr":' + display_ide_attr($p) + ', "id":"'+$p->buildKey()+ '","text":"' + $p->id() + '", "icon":"/ide/pure/icons/modelElements/primitive.png"}', @@ -230,5 +230,3 @@ function <> meta::pure::ide::tacticalDeprecated(element:Package[ ($model->isNotEmpty() && $element.package == $model && !$element.name->in(['domain', 'producers', 'external', 'consumers'])) ; } - - diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/src/main/resources/pure_ide/testing.pure b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/src/main/resources/pure_ide/testing.pure new file mode 100644 index 00000000000..4d5ab99fff8 --- /dev/null +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-pure/src/main/resources/pure_ide/testing.pure @@ -0,0 +1,31 @@ +// Copyright 2024 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. + +function meta::pure::ide::testing::getPCTAdapters():Pair[*] +{ + meta::pure::test::pct::PCT->stereotype('adapter').modelElements->map(fn| + let name = $fn.taggedValues->filter(t|$t.tag.value == 'adapterName')->first().value; + if($name->isEmpty(),|'',|$name->toOne())->pair($fn->cast(@PackageableElement)->elementToPath()); + ) +} + +function meta::pure::ide::testing::isTest(f:FunctionDefinition[1]):Boolean[1] +{ + !$f->cast(@AnnotatedElement).stereotypes->filter(st|$st == test->stereotype('Test') || $st == meta::pure::test::pct::PCT->stereotype('test'))->isEmpty(); +} + +function meta::pure::ide::testing::isPCT(f:FunctionDefinition[1]):Boolean[1] +{ + !$f->cast(@AnnotatedElement).stereotypes->filter(st|$st == meta::pure::test::pct::PCT->stereotype('test'))->isEmpty(); +} \ No newline at end of file diff --git a/legend-engine-pure/legend-engine-pure-ide/pom.xml b/legend-engine-pure/legend-engine-pure-ide/pom.xml index fd789dddabc..a5c0eee6470 100644 --- a/legend-engine-pure/legend-engine-pure-ide/pom.xml +++ b/legend-engine-pure/legend-engine-pure-ide/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-functions-javaCompiler-pure/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-functions-javaCompiler-pure/pom.xml index d4201ebcdb4..057ef9e9cbe 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-functions-javaCompiler-pure/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-functions-javaCompiler-pure/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-pure-runtime-javaCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-functions-javaCompiler-pure diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler/pom.xml index fa7a2020ee4..bfbbd380909 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-pure-runtime-javaCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/pom.xml index 481365e37ce..354f9b77576 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-pure-runtime-javaCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileAndExecuteJava.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileAndExecuteJava.java index 2eda9979f0e..aa7f66d9ff5 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileAndExecuteJava.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileAndExecuteJava.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.engine.external.language.java.runtime.compiler.shared.PureCompileAndExecuteJava; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -40,7 +41,7 @@ public CompileAndExecuteJava(FunctionExecutionInterpreted functionExecution, Mod } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { ListIterable javaSources = params.get(0).getValueForMetaPropertyToMany(M3Properties.values); CoreInstance compilationConfig = params.get(1).getValueForMetaPropertyToOne(M3Properties.values); diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileJava.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileJava.java index e8fd7bf95c0..3a08e88b6c2 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileJava.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler/src/main/java/org/finos/legend/engine/external/language/java/runtime/compiler/interpreted/natives/CompileJava.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.engine.external.language.java.runtime.compiler.shared.PureCompileAndExecuteJava; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -40,7 +41,7 @@ public CompileJava(FunctionExecutionInterpreted functionExecution, ModelReposito } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { ListIterable javaSources = params.get(0).getValueForMetaPropertyToMany(M3Properties.values); CoreInstance compilationConfig = params.get(1).getValueForMetaPropertyToOne(M3Properties.value); diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-shared-functions-javaCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-shared-functions-javaCompiler/pom.xml index b3e8716bb24..2a60b0e0901 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-shared-functions-javaCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/legend-engine-pure-runtime-java-extension-shared-functions-javaCompiler/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-pure-runtime-javaCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-pure-runtime-java-extension-shared-functions-javaCompiler diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/pom.xml index 635f6912ab8..d4098a04daa 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-javaCompiler/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-pure-runtime - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/pom.xml index fff80270c33..9e98337314a 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-legendCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/src/main/resources/core_external_compiler/compiler.pure b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/src/main/resources/core_external_compiler/compiler.pure index 4c6359d77d3..073f41a19dc 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/src/main/resources/core_external_compiler/compiler.pure +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-functions-legendCompiler-pure/src/main/resources/core_external_compiler/compiler.pure @@ -19,3 +19,5 @@ import meta::pure::mapping::*; native function meta::legend::compile(s:String[1]):PackageableElement[*]; native function meta::legend::compileVS(s:String[1]):Any[1]; + +native function meta::legend::compilePMCD(pmcdJSON:String[1]):PackageableElement[*]; diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/pom.xml index 7aa1a723bdc..32a542dc09c 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-legendCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/compiled/CompileExtensionCompiled.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/compiled/CompileExtensionCompiled.java index 562fd431ee3..47d03bc8f10 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/compiled/CompileExtensionCompiled.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/compiled/CompileExtensionCompiled.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.factory.Lists; import org.finos.legend.engine.pure.runtime.compiler.compiled.natives.LegendCompile; +import org.finos.legend.engine.pure.runtime.compiler.compiled.natives.LegendCompilePMCD; import org.finos.legend.engine.pure.runtime.compiler.compiled.natives.LegendCompileVS; import org.finos.legend.pure.runtime.java.compiled.extension.BaseCompiledExtension; import org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension; @@ -26,7 +27,7 @@ public CompileExtensionCompiled() { super( "core_external_compiler", - () -> Lists.fixedSize.with(new LegendCompile(), new LegendCompileVS()), + () -> Lists.fixedSize.with(new LegendCompile(), new LegendCompileVS(), new LegendCompilePMCD()), Lists.fixedSize.with(), Lists.fixedSize.empty(), Lists.fixedSize.empty()); diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/compiled/natives/LegendCompilePMCD.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/compiled/natives/LegendCompilePMCD.java new file mode 100644 index 00000000000..435e8646305 --- /dev/null +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/compiled/natives/LegendCompilePMCD.java @@ -0,0 +1,65 @@ +// Copyright 2022 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. + +package org.finos.legend.engine.pure.runtime.compiler.compiled.natives; + +import org.eclipse.collections.api.list.ListIterable; +import org.eclipse.collections.api.list.MutableList; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.execution.ExecutionSupport; +import org.finos.legend.pure.m3.navigation.Instance; +import org.finos.legend.pure.m3.navigation.M3Properties; +import org.finos.legend.pure.m3.navigation.ProcessorSupport; +import org.finos.legend.pure.m4.coreinstance.CoreInstance; +import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport; +import org.finos.legend.pure.runtime.java.compiled.generation.ProcessorContext; +import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNative; +import org.finos.legend.pure.runtime.java.compiled.generation.processors.valuespecification.ValueSpecificationProcessor; + +public class LegendCompilePMCD extends AbstractNative +{ + public LegendCompilePMCD() + { + super("compilePMCD_String_1__PackageableElement_MANY_"); + } + + @Override + public String build(CoreInstance topLevelElement, CoreInstance functionExpression, ListIterable listIterable, ProcessorContext processorContext) + { + final ProcessorSupport processorSupport = processorContext.getSupport(); + final ListIterable parametersValues = Instance.getValueForMetaPropertyToManyResolved(functionExpression, M3Properties.parametersValues, processorSupport); + + String code = ValueSpecificationProcessor.processValueSpecification(topLevelElement, parametersValues.get(0), processorContext); + + return "org.finos.legend.engine.pure.runtime.compiler.compiled.natives.LegendCompilePMCD.compileExecPMCD(" + code + ", es)"; + } + + @Override + public String buildBody() + { + return "new SharedPureFunction()\n" + + " {\n" + + " @Override\n" + + " public Object execute(ListIterable vars, final ExecutionSupport es)\n" + + " {\n" + + " return org.finos.legend.engine.pure.runtime.compiler.compiled.natives.LegendCompilePMCD.compileExecPMCD((String) vars.get(0), es);\n" + + " }\n" + + " }"; + } + + public static MutableList compileExecPMCD(String code, final ExecutionSupport es) + { + return org.finos.legend.engine.pure.runtime.compiler.shared.LegendCompile.doCompilePMCD(code, ((CompiledExecutionSupport) es).getProcessorSupport().getMetadata()); + } +} diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/pom.xml index aa4ab1ce5ed..a4d5f452311 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-legendCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -67,7 +67,6 @@ legend-pure-m2-dsl-diagram-grammar runtime - org.eclipse.collections eclipse-collections-api diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/CompileExtensionInterpreted.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/CompileExtensionInterpreted.java index 0299c33682e..f87383dcaec 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/CompileExtensionInterpreted.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/CompileExtensionInterpreted.java @@ -17,6 +17,7 @@ import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.tuple.Tuples; import org.finos.legend.engine.pure.runtime.compiler.interpreted.natives.LegendCompile; +import org.finos.legend.engine.pure.runtime.compiler.interpreted.natives.LegendCompilePMCD; import org.finos.legend.engine.pure.runtime.compiler.interpreted.natives.LegendCompileVS; import org.finos.legend.pure.runtime.java.interpreted.extension.BaseInterpretedExtension; import org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension; @@ -27,7 +28,8 @@ public CompileExtensionInterpreted() { super(Lists.mutable.with( Tuples.pair("compile_String_1__PackageableElement_MANY_", LegendCompile::new), - Tuples.pair("compileVS_String_1__Any_1_", LegendCompileVS::new) + Tuples.pair("compileVS_String_1__Any_1_", LegendCompileVS::new), + Tuples.pair("compilePMCD_String_1__PackageableElement_MANY_", LegendCompilePMCD::new) )); } diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompile.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompile.java index 28fb5447814..20167c74449 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompile.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompile.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -45,7 +46,7 @@ public LegendCompile(FunctionExecutionInterpreted functionExecution, ModelReposi } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String code = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); MutableList createdElements = org.finos.legend.engine.pure.runtime.compiler.shared.LegendCompile.doCompile(code, new InterpretedMetadata(processorSupport)); diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompilePMCD.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompilePMCD.java new file mode 100644 index 00000000000..8fa9c83dd15 --- /dev/null +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompilePMCD.java @@ -0,0 +1,57 @@ +// Copyright 2022 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. + +package org.finos.legend.engine.pure.runtime.compiler.interpreted.natives; + +import org.eclipse.collections.api.list.ListIterable; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; +import org.finos.legend.pure.m3.compiler.Context; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; +import org.finos.legend.pure.m3.exception.PureExecutionException; +import org.finos.legend.pure.m3.navigation.Instance; +import org.finos.legend.pure.m3.navigation.M3Properties; +import org.finos.legend.pure.m3.navigation.ProcessorSupport; +import org.finos.legend.pure.m3.navigation.ValueSpecificationBootstrap; +import org.finos.legend.pure.m4.ModelRepository; +import org.finos.legend.pure.m4.coreinstance.CoreInstance; +import org.finos.legend.pure.runtime.java.interpreted.ExecutionSupport; +import org.finos.legend.pure.runtime.java.interpreted.FunctionExecutionInterpreted; +import org.finos.legend.pure.runtime.java.interpreted.VariableContext; +import org.finos.legend.pure.runtime.java.interpreted.natives.InstantiationContext; +import org.finos.legend.pure.runtime.java.interpreted.natives.NativeFunction; +import org.finos.legend.pure.runtime.java.interpreted.profiler.Profiler; + +import java.util.Stack; + +public class LegendCompilePMCD extends NativeFunction +{ + private final FunctionExecutionInterpreted functionExecution; + + public LegendCompilePMCD(FunctionExecutionInterpreted functionExecution, ModelRepository modelRepository) + { + this.functionExecution = functionExecution; + } + + @Override + public CoreInstance execute(ListIterable params, Stack> stack, Stack> stack1, VariableContext variableContext, MutableStack coreInstance, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + { + String code = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); + + MutableList createdElements = null; + createdElements = org.finos.legend.engine.pure.runtime.compiler.shared.LegendCompile.doCompilePMCD(code, new InterpretedMetadata(processorSupport)); + return ValueSpecificationBootstrap.wrapValueSpecification(createdElements, true, functionExecution.getProcessorSupport()); + } +} diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompileVS.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompileVS.java index b68fb1763f3..6f25484cddc 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompileVS.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompileVS.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -39,7 +40,7 @@ public LegendCompileVS(FunctionExecutionInterpreted functionExecution, ModelRepo } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { String code = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); return org.finos.legend.engine.pure.runtime.compiler.shared.LegendCompile.doCompileVS(code, new InterpretedMetadata(processorSupport)); diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/pom.xml index c1558d8763b..73c58cc11a9 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-legendCompiler - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -92,5 +92,14 @@ junit junit + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/shared/LegendCompile.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/shared/LegendCompile.java index a9f5a324494..21052e1138a 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/shared/LegendCompile.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/main/java/org/finos/legend/engine/pure/runtime/compiler/shared/LegendCompile.java @@ -14,6 +14,8 @@ package org.finos.legend.engine.pure.runtime.compiler.shared; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.language.pure.compiler.toPureGraph.HelperModelBuilder; @@ -22,9 +24,9 @@ import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex; +import org.finos.legend.engine.shared.core.ObjectMapperFactory; import org.finos.legend.engine.shared.core.deployment.DeploymentMode; import org.finos.legend.engine.shared.core.identity.Identity; -import org.finos.legend.engine.shared.core.identity.factory.*; import org.finos.legend.engine.shared.core.operational.Assert; import org.finos.legend.pure.m3.coreinstance.Package; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.ModelElementAccessor; @@ -55,6 +57,27 @@ public static ValueSpecification doCompileVS(String code, Metadata metadata) return ((ConcreteFunctionDefinition) extractCreatedElementFromCompiledGraph(data, pm).getFirst())._expressionSequence().getFirst(); } + public static MutableList doCompilePMCD(String code, Metadata metadata) + { + // Parse + ObjectMapper objectMapper = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports(); + PureModelContextData data = null; + try + { + data = objectMapper.readValue(code, PureModelContextData.class); + } + catch (JsonProcessingException e) + { + throw new RuntimeException(e); + } + + // Compile + PureModel pm = org.finos.legend.engine.language.pure.compiler.Compiler.compile(data, DeploymentMode.PROD, Identity.getAnonymousIdentity().getName(), "", metadata); + + // Extract Compiled created elements + return extractCreatedElementFromCompiledGraph(data, pm); + } + private static MutableList extractCreatedElementFromCompiledGraph(PureModelContextData pureModelContextData, PureModel pureModel) { return ListIterate.collectIf(pureModelContextData.getElements(), diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/test/java/org/finos/legend/engine/pure/runtime/compiler/test/LegendCompileTest.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/test/java/org/finos/legend/engine/pure/runtime/compiler/test/LegendCompileTest.java index 4474a2e780d..712fb6a6afb 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/test/java/org/finos/legend/engine/pure/runtime/compiler/test/LegendCompileTest.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/legend-engine-pure-runtime-java-extension-shared-functions-legendCompiler/src/test/java/org/finos/legend/engine/pure/runtime/compiler/test/LegendCompileTest.java @@ -14,7 +14,12 @@ package org.finos.legend.engine.pure.runtime.compiler.test; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.eclipse.collections.impl.tuple.Tuples; +import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; +import org.finos.legend.engine.shared.core.ObjectMapperFactory; import org.finos.legend.pure.m3.execution.FunctionExecution; import org.finos.legend.pure.m3.serialization.runtime.PureRuntime; import org.junit.Test; @@ -127,6 +132,23 @@ public void testValueSpecificationEmbeddedPure() "assertEquals('X X Test', $x);"); } + @Test + public void testPMCD() throws JsonProcessingException + { + Class test = new Class(); + test.name = "a"; + test._package = "test::class"; + + PureModelContextData pmcd = PureModelContextData.newBuilder().withElement(test).build(); + ObjectMapper objectMapper = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports(); + String pmcdJson = objectMapper.writeValueAsString(pmcd); + + test("let x = meta::legend::compilePMCD('" + pmcdJson + "');\n" + + "let p = $x->at(0)->cast(@Class).name;\n " + + "assertEquals('a', $p);" + ); + } + private void test(String code) diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/pom.xml index d4ca8d9088b..cfc33f777e4 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-legendCompiler/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-pure-runtime - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-functions-planExecution-pure/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-functions-planExecution-pure/pom.xml index 0de6b35f011..d076b0ad19a 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-functions-planExecution-pure/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-functions-planExecution-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-planExecution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/pom.xml index cf8e4794ebc..70f0b9e022f 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-planExecution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/compiled/natives/LegendExecute.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/compiled/natives/LegendExecute.java index 085cdd0554e..6209255fab9 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/compiled/natives/LegendExecute.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-compiled-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/compiled/natives/LegendExecute.java @@ -19,9 +19,11 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.Optional; +import java.util.Stack; import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.list.ListIterable; import org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.ListAccessor; import org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair; @@ -80,7 +82,7 @@ else if (variableOrVariables == null) } Map planVariables = pureToPlanVariables(Optional.ofNullable(variables).orElse(Lists.fixedSize.empty())); - return org.finos.legend.engine.pure.runtime.execution.shared.LegendExecute.doExecute(planAsJson, planVariables); + return org.finos.legend.engine.pure.runtime.execution.shared.LegendExecute.doExecute(planAsJson, planVariables, Stacks.mutable.empty()); } private static Map pureToPlanVariables(RichIterable> variables) diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/pom.xml index fa2e9167b39..4472a23a26d 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-planExecution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/interpreted/natives/LegendExecute.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/interpreted/natives/LegendExecute.java index 8f9070b7cd0..55a458fc71d 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/interpreted/natives/LegendExecute.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-interpreted-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/interpreted/natives/LegendExecute.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -52,14 +53,14 @@ public LegendExecute(FunctionExecutionInterpreted functionExecution, ModelReposi } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance planAsJson = params.get(0); CoreInstance vars = params.get(1); String planAsJsonValue = Instance.getValueForMetaPropertyToOneResolved(planAsJson, M3Properties.values, processorSupport).getName(); Map planVars = this.pureToPlanVariables(vars, processorSupport); - String result = org.finos.legend.engine.pure.runtime.execution.shared.LegendExecute.doExecute(planAsJsonValue, planVars); + String result = org.finos.legend.engine.pure.runtime.execution.shared.LegendExecute.doExecute(planAsJsonValue, planVars, functionExpressionCallStack); return ValueSpecificationBootstrap.newStringLiteral(this.repository, result, processorSupport); } diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/pom.xml index a4e07f01a21..12a1d7ac2bf 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-planExecution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/shared/LegendExecute.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/shared/LegendExecute.java index 7e1ad67e0bc..f2d37980677 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/shared/LegendExecute.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/legend-engine-pure-runtime-java-extension-shared-functions-planExecution/src/main/java/org/finos/legend/engine/pure/runtime/execution/shared/LegendExecute.java @@ -14,6 +14,7 @@ package org.finos.legend.engine.pure.runtime.execution.shared; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.engine.plan.execution.PlanExecutor; import org.finos.legend.engine.plan.execution.result.ConstantResult; import org.finos.legend.engine.plan.execution.result.Result; @@ -23,6 +24,7 @@ import org.finos.legend.engine.shared.core.identity.factory.IdentityFactory; import org.finos.legend.engine.shared.core.kerberos.SubjectTools; import org.finos.legend.pure.m3.exception.PureExecutionException; +import org.finos.legend.pure.m4.coreinstance.CoreInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +35,7 @@ public class LegendExecute { private static final Logger LOGGER = LoggerFactory.getLogger(LegendExecute.class); - public static String doExecute(String jsonPlan, Map variables) + public static String doExecute(String jsonPlan, Map variables, MutableStack functionExpressionCallStack) { // create plan executor PlanExecutor planExecutor = PlanExecutor.newPlanExecutorWithAvailableStoreExecutors(true); @@ -70,7 +72,7 @@ else if (result instanceof ConstantResult) catch (Exception e) { LOGGER.error("Failed to execute plan", e); - throw new PureExecutionException("Failed to execute plan - " + e.getClass().getSimpleName() + " - " + e.getMessage(), e); + throw new PureExecutionException("Failed to execute plan - " + e.getClass().getSimpleName() + " - " + e.getMessage(), e, functionExpressionCallStack); } } } diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/pom.xml index eaa0559247a..c6291c9e9d8 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-planExecution/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-pure-runtime - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-functions-pureExtensions-pure/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-functions-pureExtensions-pure/pom.xml index 34761994dce..0cf1bf012f3 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-functions-pureExtensions-pure/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-functions-pureExtensions-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-pureExtensions - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions/pom.xml index 72986d1c394..637542536b9 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-pureExtensions - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/pom.xml index 3e0f042d7e1..37281e740ed 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-pureExtensions - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/src/main/java/org/finos/legend/engine/pure/runtime/extensions/interpreted/natives/LegendExtensions.java b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/src/main/java/org/finos/legend/engine/pure/runtime/extensions/interpreted/natives/LegendExtensions.java index 70001ed23e5..fe46bd09a56 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/src/main/java/org/finos/legend/engine/pure/runtime/extensions/interpreted/natives/LegendExtensions.java +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-interpreted-functions-pureExtensions/src/main/java/org/finos/legend/engine/pure/runtime/extensions/interpreted/natives/LegendExtensions.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.engine.pure.code.core.LegendPureCoreExtension; import org.finos.legend.engine.pure.code.core.PureCoreExtensionLoader; @@ -49,23 +50,23 @@ public LegendExtensions(FunctionExecutionInterpreted functionExecution, ModelRep } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { MutableList allSignatures = PureCoreExtensionLoader.extensions().collect(LegendPureCoreExtension::functionSignature); if (allSignatures.contains(null)) { String message = PureCoreExtensionLoader.extensions().select(c -> c.functionSignature() == null).collect(z -> z.getClass().getSimpleName() + " didn't define a functionSignature!").makeString(", "); - throw new PureExecutionException(message); + throw new PureExecutionException(message, functionExpressionCallStack); } - return ValueSpecificationBootstrap.wrapValueSpecification(allSignatures.flatCollect(this::eval), true, processorSupport); + return ValueSpecificationBootstrap.wrapValueSpecification(allSignatures.flatCollect(x -> eval(x, functionExpressionCallStack)), true, processorSupport); } - private ListIterable eval(String name) throws PureExecutionException + private ListIterable eval(String name, MutableStack functionExpressionCallStack) throws PureExecutionException { CoreInstance func = _Package.getByUserPath(name, functionExecution.getRuntime().getProcessorSupport()); if (func == null) { - throw new PureExecutionException("The function '" + name + "' can't be found in the Pure graph."); + throw new PureExecutionException("The function '" + name + "' can't be found in the Pure graph.", functionExpressionCallStack); } CoreInstance ci = functionExecution.start(func, Lists.mutable.empty()); return ci.getValueForMetaPropertyToMany("values"); diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-shared-functions-pureExtensions/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-shared-functions-pureExtensions/pom.xml index 51998e6a2a8..59a7563fbdf 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-shared-functions-pureExtensions/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/legend-engine-pure-runtime-java-extension-shared-functions-pureExtensions/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-pure-runtime-pureExtensions - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/pom.xml index f7aea3bcbdd..d81acaa82f9 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/legend-engine-pure-runtime-pureExtensions/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-pure-runtime - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/legend-engine-pure-runtime/pom.xml b/legend-engine-pure/legend-engine-pure-runtime/pom.xml index 4386071cef1..77081e37613 100644 --- a/legend-engine-pure/legend-engine-pure-runtime/pom.xml +++ b/legend-engine-pure/legend-engine-pure-runtime/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-pure/pom.xml b/legend-engine-pure/pom.xml index cb653a7dfc5..b1a0fcb10dc 100644 --- a/legend-engine-pure/pom.xml +++ b/legend-engine-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-http-api/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-http-api/pom.xml index 16d3151f829..361208bcc2e 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-http-api/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-binding - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-pure/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-pure/pom.xml index 55a804f333b..022f823e22e 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-pure/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/legend-engine-xt-analytics-binding-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-binding - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/pom.xml index e6441509bca..ddab4298ba1 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-binding/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-http-api/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-http-api/pom.xml index 69682a58779..dec8c9b0314 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-http-api/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-class - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-pure/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-pure/pom.xml index 7a9ab86a25c..75d29274d58 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-pure/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-class/legend-engine-xt-analytics-class-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-class - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-class/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-class/pom.xml index cd67578f75f..48149659966 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-class/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-class/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-http-api/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-http-api/pom.xml index cc5239f8705..793b7a767b6 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-http-api/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-function - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-pure/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-pure/pom.xml index 419cbfbde71..9e535f8334e 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-pure/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-function/legend-engine-xt-analytics-function-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-function - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-function/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-function/pom.xml index e5bbdbbe43f..9e854f9d6a1 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-function/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-function/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-http-api/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-http-api/pom.xml index 27149a356f3..07ea91cb6b7 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-http-api/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-http-api/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-analytics-lineage org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/pom.xml index 8199820a27f..f9941875a97 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-analytics-lineage org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -204,11 +204,6 @@ legend-engine-pure-functions-standard-pure ${project.version} - - org.finos.legend.pure - legend-pure-m2-dsl-graph-pure - ${legend.pure.version} - diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure index 83380aaa840..99466f9f4e7 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/lineageTests.pure @@ -493,3 +493,52 @@ function <> meta::analytics::lineage::tests::re '[type: [ProductClassificationSystemTable.id , ProductClassificationSystemTable.name , ProductTable.classificationSystemId ]]', $lineage); } + +###Pure +import meta::relational::tests::*; +import meta::relational::tests::model::simple::*; +function <> meta::analytics::lineage::tests::relational::testMapWithPath():Boolean[1] +{ + let lineage = meta::analytics::lineage::computeLineage( | Person.all() + ->filter(x | $x->map(#/Person/firm/legalName#) != 'Goldman Sachs') + ->project([ + p|$p.lastName + ], + [ + 'employeeLastName' + ]) + , + simpleRelationalMapping, meta::external::store::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); + meta::analytics::lineage::assertLineage(['Lambda', 'tb_dbIncdefaultfirmTable','tb_dbIncdefaultpersonTable','db_dbInc'], + ['Lambda', 'meta::relational::tests::model::simple::Firm','meta::relational::tests::model::simple::Person','pack_meta::relational::tests::model::simple'], + '[employeeLastName: [personTable.LASTNAME ]]', + $lineage); +} + +###Pure +import meta::legend::*; +import meta::pure::mapping::*; +import meta::core::runtime::*; +import meta::pure::runtime::*; + +function <> meta::analytics::lineage::tests::relational::testSemiStructuredMapping():Boolean[1] +{ + let grammar = readFile('/core_analytics_lineage/tests/resources/lineageTestSchemaForSemiStructuredJoin.txt')->toOne(); + let elements = compileLegendGrammar($grammar); + let runtime = $elements->filter(e|$e->instanceOf(PackageableRuntime))->at(0)->cast(@PackageableRuntime).runtimeValue->cast(@Runtime); + let mapping = $elements->filter(e|$e->instanceOf(Mapping))->at(0)->cast(@Mapping); + let function = $elements->filter(e|$e->instanceOf(FunctionDefinition))->at(0)->cast(@FunctionDefinition<{->TabularDataSet[1]}>); + let lineage = meta::analytics::lineage::computeLineage($function, $mapping, $runtime, meta::relational::extension::relationalExtensions()); + + let expectedRelationTree = 'root\n' + + ' ------> (t) PersonTable [ID, PERSON_DETAILS]\n' + + ' ------> (t) PersonTable(equal_rootID_Firm_Person_d#4_d_m2leftJoinKey_0) [ID, PERSON_DETAILS]\n' + + ' ------> (t) FirmTable(equal_extractFromSemiStructured_explodedflattened_prop_ID_VARCHAR_FirmTableID) [ID, LEGAL_NAME]\n'; + let actualRelationTree = meta::pure::lineage::scanRelations::relationTreeAsString($lineage.relationTree); + assertEquals($expectedRelationTree, $actualRelationTree); + + meta::analytics::lineage::assertLineage(['my::test::testSemiStructuredMappingQuery__TabularDataSet_1_','tb_H2DBTEST_SCHEMAPersonTable','tb_H2DBTEST_SCHEMAFirmTable','db_H2DB'], + ['my::test::testSemiStructuredMappingQuery__TabularDataSet_1_','my::model::Person','my::model::Firm','pack_my::model'], + '[employeeName: [PersonTable.PERSON_DETAILS ], firmName: [FirmTable.ID , FirmTable.LEGAL_NAME , PersonTable.PERSON_DETAILS ]]', + $lineage); +} \ No newline at end of file diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/resources/lineageTestSchemaForSemiStructuredJoin.txt b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/resources/lineageTestSchemaForSemiStructuredJoin.txt new file mode 100644 index 00000000000..61d695c8ebf --- /dev/null +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/resources/lineageTestSchemaForSemiStructuredJoin.txt @@ -0,0 +1,117 @@ +###Relational +Database my::store::H2DB +( + Schema TEST_SCHEMA + ( + Table FirmTable + ( + ID VARCHAR(255) PRIMARY KEY, + LEGAL_NAME VARCHAR(255) + ) + Table PersonTable + ( + ID VARCHAR(255) PRIMARY KEY, + PERSON_DETAILS SEMISTRUCTURED NOT NULL + ) + ) + Join Firm_Person(extractFromSemiStructured(explodeSemiStructured(TEST_SCHEMA.PersonTable.PERSON_DETAILS, 'firm', 'SEMISTRUCTURED'), 'ID', 'VARCHAR') = TEST_SCHEMA.FirmTable.ID) +) + + +###Pure +Class my::model::Firm +{ + ID: String[1]; + legalName: String[1]; +} + +Class my::model::Person +{ + ID: String[1]; + name: String[1]; + firm: my::model::Firm[0..1]; +} + +function my::test::testSemiStructuredMappingQuery(): meta::pure::tds::TabularDataSet[1] +{ + my::model::Person.all()->project( + [ + p|$p.name, + p|$p.firm.legalName + ], + [ + 'employeeName', + 'firmName' + ] + ) +} + + +###Mapping +Mapping my::mapping::H2Mapping +( + *my::model::Firm: Relational + { + ~primaryKey + ( + [my::store::H2DB]TEST_SCHEMA.FirmTable.ID + ) + ~mainTable [my::store::H2DB]TEST_SCHEMA.FirmTable + ID: [my::store::H2DB]TEST_SCHEMA.FirmTable.ID, + legalName: [my::store::H2DB]TEST_SCHEMA.FirmTable.LEGAL_NAME + } + *my::model::Person: Relational + { + ~primaryKey + ( + [my::store::H2DB]TEST_SCHEMA.PersonTable.ID + ) + ~mainTable [my::store::H2DB]TEST_SCHEMA.PersonTable + ID: [my::store::H2DB]TEST_SCHEMA.PersonTable.ID, + name: extractFromSemiStructured([my::store::H2DB]TEST_SCHEMA.PersonTable.PERSON_DETAILS, 'name', 'VARCHAR'), + firm[my_model_Firm]: [my::store::H2DB]@Firm_Person + } +) + + +###Connection +RelationalDatabaseConnection my::connection::H2Connection +{ + store: my::store::H2DB; + type: H2; + quoteIdentifiers: false; + specification: LocalH2 + { + testDataSetupSqls: [ + 'DROP SCHEMA IF EXISTS TEST_SCHEMA;', + 'CREATE SCHEMA TEST_SCHEMA;', + 'SET SCHEMA TEST_SCHEMA;', + 'DROP TABLE IF EXISTS FirmTable;', + 'CREATE TABLE FirmTable(ID VARCHAR(255) PRIMARY KEY, FIRM_DETAILS VARCHAR(255));', + 'INSERT INTO FirmTable(ID,FIRM_DETAILS) VALUES (\'1\',\'{"legalName": "GS", "city": "New York"}\');', + 'INSERT INTO FirmTable(ID,FIRM_DETAILS) VALUES (\'2\',\'{"legalName": "BOFA", "city": "Charlotte"}\');', + 'DROP TABLE IF EXISTS PersonTable;', + 'CREATE TABLE PersonTable(ID VARCHAR(255) PRIMARY KEY, PERSON_DETAILS VARCHAR(1000));', + 'INSERT INTO PersonTable(ID,PERSON_DETAILS) VALUES (\'1\',\'{"name": "ABC", "firm": {"ID": 1, "joinDate": "2024-09-01"}}\');', + 'INSERT INTO PersonTable(ID,PERSON_DETAILS) VALUES (\'2\',\'{"name": "XYZ", "firm": {"ID": 2, "joinDate": "2024-10-01"}}\');' + ]; + }; + auth: DefaultH2; +} + + +###Runtime +Runtime my::runtime::H2Runtime +{ + mappings: + [ + my::mapping::H2Mapping + ]; + connections: + [ + my::store::H2DB: + [ + connection_1: my::connection::H2Connection + ] + ]; +} \ No newline at end of file diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/pom.xml index b8efcee226d..249432b0bcf 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-http-api/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-http-api/pom.xml index be869036dd4..193c189c087 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-http-api/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-http-api/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-analytics-mapping org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 Legend Engine - XT - Analytics - Mapping - HTTP - API diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-protocol/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-protocol/pom.xml index f159b87320e..de4d7eeba1c 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-protocol/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-mapping - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 Legend Engine - XT - Analytics - Mapping - Protocol diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/pom.xml index 544991ce283..76e0c0ac1d4 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-analytics-mapping org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/pom.xml index ee025794038..294c03e0c2b 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-http-api/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-http-api/pom.xml index b93702a3bad..25c052fd98d 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-http-api/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-http-api/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-analytics-quality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-pure/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-pure/pom.xml index 2f56eb8571f..92d04f0db35 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-pure/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/legend-engine-xt-analytics-quality-pure/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-analytics-quality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/pom.xml index a8b0c86c6a1..4563235bf2d 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-quality/pom.xml @@ -2,7 +2,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-generation/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-generation/pom.xml index 325c1afb716..7f9512d88ee 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-generation/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-analytics-search - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-pure/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-pure/pom.xml index 32f814a0b81..6a9c2a8895d 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-pure/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-search/legend-engine-xt-analytics-search-pure/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-analytics-search org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-search/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-search/pom.xml index 21604fda900..6a2e925801a 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-search/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-search/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement-http-api/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement-http-api/pom.xml index 29828efd0f1..e07b16fa13c 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement-http-api/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement-http-api/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-analytics-store org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-analytics-store-entitlement-http-api diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement/pom.xml index 2c6de27e2e4..811ce9a36be 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-store/legend-engine-xt-analytics-store-entitlement/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-analytics-store org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-store/pom.xml b/legend-engine-xts-analytics/legend-engine-xts-analytics-store/pom.xml index 38deca57b11..39d7c50dcf7 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-store/pom.xml +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-store/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-analytics - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-analytics/pom.xml b/legend-engine-xts-analytics/pom.xml index 07bb1f53175..61c47afd2eb 100644 --- a/legend-engine-xts-analytics/pom.xml +++ b/legend-engine-xts-analytics/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-arrow/legend-engine-xt-arrow-pure/pom.xml b/legend-engine-xts-arrow/legend-engine-xt-arrow-pure/pom.xml index 16bfca9bf24..fea77d16634 100644 --- a/legend-engine-xts-arrow/legend-engine-xt-arrow-pure/pom.xml +++ b/legend-engine-xts-arrow/legend-engine-xt-arrow-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-arrow - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-arrow/legend-engine-xt-arrow-runtime/pom.xml b/legend-engine-xts-arrow/legend-engine-xt-arrow-runtime/pom.xml index f4a78c39420..2cd9536243c 100644 --- a/legend-engine-xts-arrow/legend-engine-xt-arrow-runtime/pom.xml +++ b/legend-engine-xts-arrow/legend-engine-xt-arrow-runtime/pom.xml @@ -3,7 +3,7 @@ org.finos.legend.engine legend-engine-xts-arrow - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-arrow/pom.xml b/legend-engine-xts-arrow/pom.xml index 16a426f159c..557410334ea 100644 --- a/legend-engine-xts-arrow/pom.xml +++ b/legend-engine-xts-arrow/pom.xml @@ -4,7 +4,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xts-arrow diff --git a/legend-engine-xts-authentication/legend-engine-xt-authentication-grammar/pom.xml b/legend-engine-xts-authentication/legend-engine-xt-authentication-grammar/pom.xml index fb8481cdbaf..3ff66e52e8a 100644 --- a/legend-engine-xts-authentication/legend-engine-xt-authentication-grammar/pom.xml +++ b/legend-engine-xts-authentication/legend-engine-xt-authentication-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-authentication - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-core/pom.xml b/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-core/pom.xml index ea56ffa05f0..b957b609c66 100644 --- a/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-core/pom.xml +++ b/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-core/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-authentication - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-gcp-federation/pom.xml b/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-gcp-federation/pom.xml index 6d35738c393..dd734ffe309 100644 --- a/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-gcp-federation/pom.xml +++ b/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-gcp-federation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-authentication - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-vault-aws/pom.xml b/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-vault-aws/pom.xml index 82874232739..c6e1a54ba01 100644 --- a/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-vault-aws/pom.xml +++ b/legend-engine-xts-authentication/legend-engine-xt-authentication-implementation-vault-aws/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-authentication - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-authentication/legend-engine-xt-authentication-protocol/pom.xml b/legend-engine-xts-authentication/legend-engine-xt-authentication-protocol/pom.xml index a456aad2562..0f97fcbda56 100644 --- a/legend-engine-xts-authentication/legend-engine-xt-authentication-protocol/pom.xml +++ b/legend-engine-xts-authentication/legend-engine-xt-authentication-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-authentication - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-authentication/legend-engine-xt-authentication-pure/pom.xml b/legend-engine-xts-authentication/legend-engine-xt-authentication-pure/pom.xml index c2758ab3678..6bfe4cf06ac 100644 --- a/legend-engine-xts-authentication/legend-engine-xt-authentication-pure/pom.xml +++ b/legend-engine-xts-authentication/legend-engine-xt-authentication-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-authentication - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-authentication/pom.xml b/legend-engine-xts-authentication/pom.xml index af384309e83..a2e62d2164b 100644 --- a/legend-engine-xts-authentication/pom.xml +++ b/legend-engine-xts-authentication/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-avro/legend-engine-xt-avro-http-api/pom.xml b/legend-engine-xts-avro/legend-engine-xt-avro-http-api/pom.xml index 76695018678..585380d60f3 100644 --- a/legend-engine-xts-avro/legend-engine-xt-avro-http-api/pom.xml +++ b/legend-engine-xts-avro/legend-engine-xt-avro-http-api/pom.xml @@ -4,7 +4,7 @@ org.finos.legend.engine legend-engine-xts-avro - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-avro-http-api diff --git a/legend-engine-xts-avro/legend-engine-xt-avro-pure/pom.xml b/legend-engine-xts-avro/legend-engine-xt-avro-pure/pom.xml index a705a54e96b..5de98642366 100644 --- a/legend-engine-xts-avro/legend-engine-xt-avro-pure/pom.xml +++ b/legend-engine-xts-avro/legend-engine-xt-avro-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-avro - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-avro/legend-engine-xt-avro/pom.xml b/legend-engine-xts-avro/legend-engine-xt-avro/pom.xml index 6a7d167a5da..57c37ef5bf9 100644 --- a/legend-engine-xts-avro/legend-engine-xt-avro/pom.xml +++ b/legend-engine-xts-avro/legend-engine-xt-avro/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-avro - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-avro/pom.xml b/legend-engine-xts-avro/pom.xml index bdae81bf5fb..4f023dce522 100644 --- a/legend-engine-xts-avro/pom.xml +++ b/legend-engine-xts-avro/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/pom.xml b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/pom.xml index 0a87fa8b43e..e9c4980bde7 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/pom.xml +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-api/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-bigqueryFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-compiler/pom.xml b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-compiler/pom.xml index 9a9fb0b5e1a..85d70b03d84 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-compiler/pom.xml +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-compiler/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-bigqueryFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-grammar/pom.xml b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-grammar/pom.xml index fab94d9c975..d6f181b927d 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-grammar/pom.xml +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-grammar/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-bigqueryFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/pom.xml b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/pom.xml index 5750b6694ee..79d023a8675 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/pom.xml +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-bigqueryFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-pure/pom.xml b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-pure/pom.xml index dc5c0c2e030..2dc68ff2072 100644 --- a/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-pure/pom.xml +++ b/legend-engine-xts-bigqueryFunction/legend-engine-xt-bigqueryFunction-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-bigqueryFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-bigqueryFunction/pom.xml b/legend-engine-xts-bigqueryFunction/pom.xml index 5272825af2f..4af986d0678 100644 --- a/legend-engine-xts-bigqueryFunction/pom.xml +++ b/legend-engine-xts-bigqueryFunction/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml index 8da347c7d78..0dcf05b3702 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-changetoken org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -44,10 +44,6 @@ org.eclipse.collections eclipse-collections-api - - org.finos.legend.engine - legend-engine-pure-code-compiled-core - org.finos.legend.engine legend-engine-xt-changetoken-pure diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java index 63bcbcd3163..2793b3383f7 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java @@ -81,20 +81,6 @@ public GenerateDiff(List newEntities, List allTypes = pureModel.getModelClasses().collect(a -> - core_pure_corefunctions_metaExtension.Root_meta_pure_functions_meta_fullPackageName_PackageableElement_1__String_1__String_1_((org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement) a, "::", pureModel.getExecutionSupport())).toSet(); - MutableList javaSources = Lists.mutable.empty(); - javaSources.addAllIterable(javaSourceCodeGenerator.generatePureCoreHelperClasses(javaSourceCodeGenerator.getProcessorContext())); - javaSources.addAllIterable(javaSourceCodeGenerator.generateCode(allTypes)); - try - { - compiler.compile(javaSources); - } - catch (PureJavaCompileException e) - { - throw new RuntimeException(e); - } } private static PureMap toPureMap(Map objectNode) diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast2Test.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast2Test.java deleted file mode 100644 index a2db314b027..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast2Test.java +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCast2Test extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::CopyValue\",\n" + - " \"source\": {\n" + - " \"@type\": \"meta::pure::changetoken::RelativeFieldReference\",\n" + - " \"path\": \"../existingValue\"\n" + - " }\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"), - "{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"someValue\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"someValue\"\n" + - " }\n" + - "}\n", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast3Test.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast3Test.java deleted file mode 100644 index bcf81fec6c3..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast3Test.java +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCast3Test extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::ChangeFieldType\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"oldFieldType\": \"Integer[1]\",\n" + - " \"newFieldType\": \"String[1]\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"), - "{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n", "ftdm:abcdefg123"), - "{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast4Test.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast4Test.java deleted file mode 100644 index 44440ecbb1f..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast4Test.java +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCast4Test extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::ChangeFieldType\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"oldFieldType\": \"String[1]\",\n" + - " \"newFieldType\": \"String[0..1]\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"), - "{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n", "ftdm:abcdefg123"), - "{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanStringTest.java deleted file mode 100644 index f1218adb444..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastBooleanStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Boolean[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"true\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": false\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:false"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanTest.java deleted file mode 100644 index 73af6a72109..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastBooleanTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Boolean[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": true\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": false\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:false"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastChainTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastChainTest.java deleted file mode 100644 index bf8d11307e0..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastChainTest.java +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.List; - -public class GenerateCastChainTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg789\",\n" + - " \"prevVersion\": \"ftdm:abcdefg456\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"def\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 200\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testVersions() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - List versions = (List) compiledClass.getMethod("versions").invoke(null); - List expected = Arrays.asList("ftdm:abcdefg123", "ftdm:abcdefg456", "ftdm:abcdefg789"); - Assert.assertEquals(expected, versions); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg789\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n" + - " ],\n" + - " \"abc\": 100, \"def\": 200\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg789\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n" + - " ],\n" + - " \"abc\": 100, \"def\": 200\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg789\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n" + - " ],\n" + - " \"abc\": 100, \"def\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayBooleanTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayBooleanTest.java deleted file mode 100644 index 301c0d38cd3..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayBooleanTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayBooleanTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Boolean[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [true]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n" + - " ],\n" + - " \"abc\": [true]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n" + - " ],\n" + - " \"abc\": [true]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n" + - " ],\n" + - " \"abc\":[false]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[false]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayEmbeddedTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayEmbeddedTest.java deleted file mode 100644 index 9f857cee3df..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayEmbeddedTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayEmbeddedTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"[1,2,3]\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\":[5,6,7]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[5, 6, 7]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayFloatTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayFloatTest.java deleted file mode 100644 index 73261130073..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayFloatTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayFloatTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Float[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [1.2, 3.4]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n" + - " ],\n" + - " \"abc\": [1.2, 3.4]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n" + - " ],\n" + - " \"abc\": [1.2, 3.4]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n" + - " ],\n" + - " \"abc\":[5.6, 7.8]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[5.6, 7.8]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayIntegerTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayIntegerTest.java deleted file mode 100644 index db67175f179..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayIntegerTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayIntegerTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [1,2,3]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\":[5,6,7]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[5, 6, 7]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayObjectTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayObjectTest.java deleted file mode 100644 index 62ec45c16e5..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayObjectTest.java +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayObjectTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1..*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [\n" + - " {\n" + - " \"@type\": \"Custom\",\n" + - " \"value\": 4.2\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n" + - " ],\n" + - " \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n" + - " ],\n" + - " \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n" + - " ],\n" + - " \"abc\":[{\"@type\": \"Custom\",\"value\": 8.8}]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[{@type=Custom, value=8.8}]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayStringTest.java deleted file mode 100644 index 769b25cf24f..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayStringTest.java +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"String[1..*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [\n" + - " \"Foo\",\n" + - " \"Bar\"\n" + - " ]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n" + - " ],\n" + - " \"abc\": [\"Foo\", \"Bar\"]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n" + - " ],\n" + - " \"abc\": [\"Foo\", \"Bar\"]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n" + - " ],\n" + - " \"abc\":[\"Something\",\"Else\"]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[Something, Else]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomEmptyTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomEmptyTest.java deleted file mode 100644 index 7a9d9a46983..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomEmptyTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomEmptyTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": []\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n" + - " ],\n" + - " \"abc\": []\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n" + - " ],\n" + - " \"abc\": []\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n" + - " ],\n" + - " \"abc\": [\"2023-06-22T18:30:01Z\"]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[2023-06-22T18:30:01Z]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomMapTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomMapTest.java deleted file mode 100644 index aa97b20e8fd..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomMapTest.java +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.finos.legend.pure.generated.Root_meta_pure_changetoken_Versions; -import org.finos.legend.pure.generated.core_pure_changetoken_changetoken_test; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomMapTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - Root_meta_pure_changetoken_Versions versions = core_pure_changetoken_changetoken_test.Root_meta_pure_changetoken_tests_getVersionsCustomMap__Versions_1_(null); - setupSuiteFromVersions(versions); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedNoEscapingTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedNoEscapingTest.java deleted file mode 100644 index d5308583c19..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedNoEscapingTest.java +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNestedNoEscapingTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", - true, false, false); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n" + - " ],\n" + - " \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n" + - " ],\n" + - " \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedTest.java deleted file mode 100644 index 3e7e2a39ffb..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNestedTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullKeywordTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullKeywordTest.java deleted file mode 100644 index 29c879d6ca3..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullKeywordTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNullKeywordTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[0..1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"null\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullStringTest.java deleted file mode 100644 index edeca56de21..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNullStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[0..1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullTest.java deleted file mode 100644 index bb3926b9983..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNullTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[0..1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": null\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectNestedVersionTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectNestedVersionTest.java deleted file mode 100644 index 64ae9119537..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectNestedVersionTest.java +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomObjectNestedVersionTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": {\n" + - " \"range\": {\n" + - " \"min\": -1,\n" + - " \"max\": 1,\n" + - " \"@type\": \"intMinMax\",\n" + - " \"round\": 0.5\n" + - " },\n" + - " \"@type\": \"Custom\",\n" + - " \"restricted\": true,\n" + - " \"value\": 0\n" + - " }\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", - true, true, true); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} \ No newline at end of file diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectTest.java deleted file mode 100644 index 0b81983ace2..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectTest.java +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomObjectTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": {\n" + - " \"range\": {\n" + - " \"min\": -1,\n" + - " \"max\": 1,\n" + - " \"@type\": \"intMinMax\",\n" + - " \"round\": 0.5\n" + - " },\n" + - " \"@type\": \"Custom\",\n" + - " \"restricted\": true,\n" + - " \"value\": 0\n" + - " }\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} \ No newline at end of file diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringNoEscapingTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringNoEscapingTest.java deleted file mode 100644 index 355b8a117c9..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringNoEscapingTest.java +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomPrimitiveStringNoEscapingTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", - true, false, false); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n" + - " ],\n" + - " \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n" + - " ],\n" + - " \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringTest.java deleted file mode 100644 index 89e157ecb15..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomPrimitiveStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveTest.java deleted file mode 100644 index c8b2886e3c2..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomPrimitiveTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"1970-01-01T00:00:01Z\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomTest.java deleted file mode 100644 index 4c3ba0d0ceb..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"value\\\":\\\"0d\\\"}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, value=1d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleStringTest.java deleted file mode 100644 index 224fbc8ca6c..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastDoubleStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"double[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"123.45\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 67.89\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:67.89"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleTest.java deleted file mode 100644 index df96a82d589..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastDoubleTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"double[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 123.45\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 67.89\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:67.89"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromJsonTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromJsonTest.java deleted file mode 100644 index 4611d8d3a95..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromJsonTest.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastFromJsonTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"safeCast\": true,\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " }\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromVersionsTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromVersionsTest.java deleted file mode 100644 index 8af0c5d917a..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromVersionsTest.java +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.finos.legend.pure.generated.*; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastFromVersionsTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - Root_meta_pure_changetoken_Version abcdefg123 = new Root_meta_pure_changetoken_Version_Impl("Anonymous_NoCounter"); - abcdefg123._version("ftdm:abcdefg123"); - Root_meta_pure_changetoken_Version abcdefg456 = new Root_meta_pure_changetoken_Version_Impl("Anonymous_NoCounter"); - abcdefg456._version("ftdm:abcdefg456"); - abcdefg456._prevVersion("ftdm:abcdefg123"); - Root_meta_pure_changetoken_AddField addField = new Root_meta_pure_changetoken_AddField_Impl("Anonymous_NoCounter"); - addField._class("meta::pure::changetoken::tests::SampleClass"); - addField._fieldName("abc"); - addField._fieldType("Integer[1]"); - addField._safeCast(true); - Root_meta_pure_changetoken_ConstValue value = new Root_meta_pure_changetoken_ConstValue_Impl("Anonymous_NoCounter"); - value._value(100L); - addField._defaultValue(value); - abcdefg456._changeTokensAdd(addField); - Root_meta_pure_changetoken_Versions versions = new Root_meta_pure_changetoken_Versions_Impl("Anonymous_NoCounter"); - versions._versionsAdd(abcdefg123); - versions._versionsAdd(abcdefg456); - setupSuiteFromVersions(versions); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastIntegerStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastIntegerStringTest.java deleted file mode 100644 index c853e37bd71..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastIntegerStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastIntegerStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"100\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveExtractTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveExtractTest.java deleted file mode 100644 index 40f9576508f..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveExtractTest.java +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastMoveExtractTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"names\",\n" + - " \"first\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"firstName\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"names\",\n" + - " \"last\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"lastName\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RemoveField\",\n" + - " \"fieldName\": \"names\",\n" + - " \"fieldType\": \"NamesClass[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"NamesClass\\\",\\\"middle\\\":\\\"\\\"}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"1d\", \"middle\":\"\", \"last\":\"2d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"3d\", \"middle\":\"\", \"last\":\"4d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"5d\", \"middle\":\"\", \"last\":\"6d\"}}]\n" + - " ],\n" + - " \"names\": {\"@type\":\"NamesClass\", \"first\":\"7d\", \"middle\":\"\", \"last\":\"8d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"1d\", \"lastName\":\"2d\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"3d\", \"lastName\":\"4d\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"5d\", \"lastName\":\"6d\"}]\n" + - " ],\n" + - " \"firstName\":\"7d\", \"lastName\":\"8d\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"1d\", \"lastName\":\"2d\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"3d\", \"lastName\":\"4d\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"5d\", \"lastName\":\"6d\"}]\n" + - " ],\n" + - " \"firstName\":\"7d\", \"lastName\":\"8d\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"1d\", \"middle\":\"\", \"last\":\"2d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"3d\", \"middle\":\"\", \"last\":\"4d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"5d\", \"middle\":\"\", \"last\":\"6d\"}}]\n" + - " ],\n" + - " \"names\": {\"@type\":\"NamesClass\", \"first\":\"7d\", \"middle\":\"\", \"last\":\"8d\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveNestedTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveNestedTest.java deleted file mode 100644 index 4d8af2165bd..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveNestedTest.java +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastMoveNestedTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\",\n" + - " \"value\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\",\n" + - " \"value\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testUpcastSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testDowncastSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testUpcastDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\", \"value\":\"5d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "Cannot overwrite with different value:5d"); - } - - @Test - public void testDowncastDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\", \"value\":\"6d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:6d"); - } - - @Test - public void testUpcastInvalidDestination() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": \"invalid\"}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "Destination is not a map: xyz"); - } - - @Test - public void testDowncastInvalidDestination() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": \"invalid\"}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "Destination is not a map: abc"); - } - - @Test - public void testUpcastInvalidSource() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"invalid\", \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "Source is not a map: abc"); - } - - @Test - public void testDowncastInvalidSource() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": \"invalid\", \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "Source is not a map: xyz"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveTest.java deleted file mode 100644 index 0241f0ab169..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveTest.java +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastMoveTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"xyz\",\n" + - " \"fieldType\": \"SampleNestedClass[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"SampleNestedClass\\\",\\\"step\\\":0,\\\"active\\\":true}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\",\n" + - " \"def\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRemoveTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRemoveTest.java deleted file mode 100644 index f02987e157c..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRemoveTest.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRemoveTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RemoveField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void tesUpcastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}"), - "Cannot remove non-default value:300"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameFieldRenamedClassTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameFieldRenamedClassTest.java deleted file mode 100644 index 09f096071f2..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameFieldRenamedClassTest.java +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenameFieldRenamedClassTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenamedClass\",\n" + - " \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:{@type=Custom, value=9d}"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:{@type=Custom, value=8d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameNestedPropertyTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameNestedPropertyTest.java deleted file mode 100644 index 3ce0a394284..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameNestedPropertyTest.java +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenameNestedPropertyTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\",\n" + - " \"value\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"abc\",\n" + - " \"valueCustom\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:9d"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:8d"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamePropertyTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamePropertyTest.java deleted file mode 100644 index 0458f6c6aba..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamePropertyTest.java +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenamePropertyTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"value\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"valueCustom\"\n" + - " ],\n" + - " \"class\": \"Custom\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:9d"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:8d"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameTest.java deleted file mode 100644 index 4fa70b49728..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameTest.java +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenameTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:{@type=Custom, value=9d}"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:{@type=Custom, value=8d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassRenameFieldTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassRenameFieldTest.java deleted file mode 100644 index 45442796a27..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassRenameFieldTest.java +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenamedClassRenameFieldTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenamedClass\",\n" + - " \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::nested::NewSampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:{@type=Custom, value=9d}"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:{@type=Custom, value=8d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassTest.java deleted file mode 100644 index 79c6b745cd6..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassTest.java +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenamedClassTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenamedClass\",\n" + - " \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringQuotesTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringQuotesTest.java deleted file mode 100644 index 15c8f783a21..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringQuotesTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastStringQuotesTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"String[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\\\"one \\\\\\\" two\\\"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"two \\\" one\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:two \" one"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringTest.java deleted file mode 100644 index ef87ca95cef..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"String[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"one \\\" two\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"two \\\" one\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:two \" one"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastUtilTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastUtilTest.java index f024e2dbc0f..3cc530a83a4 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastUtilTest.java +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastUtilTest.java @@ -39,20 +39,6 @@ public static void setupSuite() throws IOException, ClassNotFoundException " {\n" + " \"@type\": \"meta::pure::changetoken::Version\",\n" + " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::ChangeFieldType\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"oldFieldType\": \"Integer[1]\",\n" + - " \"newFieldType\": \"String[1]\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + " }\n" + " ]\n" + "}\n"); diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionCustomTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionCustomTest.java deleted file mode 100644 index f295ffd153d..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionCustomTest.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastVersionCustomTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"$type$\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"$type$\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"$type$\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"$type$\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"$type$\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", "$type$", "$version$"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"$version$\":\"ftdm:abcdefg123\", \n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"$version$\":\"ftdm:abcdefg123\", \n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"$version$\":\"ftdm:abcdefg123\", \n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionNullTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionNullTest.java deleted file mode 100644 index b52338ce3af..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionNullTest.java +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2024 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. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastVersionNullTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", "@type", null); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123", "ftdm:abcdefg456"), - "{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123", "ftdm:abcdefg456"), - "{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123", "ftdm:abcdefg456"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml index f8e3220745a..dcc2ce8c256 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-changetoken - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test.pure deleted file mode 100644 index 29c95376b47..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test.pure +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2024 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 meta::pure::changetoken::cast_generation::*; -import meta::pure::changetoken::tests::*; - -function <> meta::pure::changetoken::tests::testToMultiplicity(): Any[*] -{ - assertToMultiplicity('0', 0, 0, PureZero); - assertToMultiplicity('1', 1, 1, PureOne); - assertToMultiplicity('0..1', 0, 1, ZeroOne); - assertToMultiplicity('2', 2, 2, []); - assertToMultiplicity('2..2', 2, 2, []); - assertToMultiplicity('*', 0, [], ZeroMany); - assertToMultiplicity('0..*', 0, [], ZeroMany); - assertToMultiplicity('1..*', 1, [], OneMany); - assertToMultiplicity('2..4', 2, 4, []); - assertToMultiplicity('0..4', 0, 4, []); - assertToMultiplicity('5..*', 5, [], []); -} - -function <> meta::pure::changetoken::tests::assertToMultiplicity(input: String[1], min: Integer[1], max: Integer[0..1], expected: Multiplicity[0..1]): Boolean[1] -{ - let multiplicity = $input->toMultiplicity(); - assertEquals($min, $multiplicity->getLowerBound()); - assertEquals($max, if($multiplicity->hasUpperBound(), | $multiplicity->getUpperBound(), | [])); - if($expected != [], | assertEquals($expected, $multiplicity), | true); -} - -function <> meta::pure::changetoken::tests::testExtractTypeMultiplicity(): Any[*] -{ - assertExtractTypeMultiplicity('String[1]', 'String', 1, 1); - assertExtractTypeMultiplicity('Integer[*]', 'Integer', 0, []); - assertExtractTypeMultiplicity('Float[0..1]', 'Float', 0, 1); - assertExtractTypeMultiplicity('Decimal[10]', 'Decimal', 10, 10); -} - -function <> meta::pure::changetoken::tests::assertExtractTypeMultiplicity(input: String[1], type: String[1], min: Integer[1], max: Integer[0..1]): Boolean[1] -{ - let typeMultiplicity = $input->extractTypeMultiplicity(); - assertEquals($type, $typeMultiplicity.first); - let multiplicity = $typeMultiplicity.second; - assertEquals($min, $multiplicity->getLowerBound()); - assertEquals($max, if($multiplicity->hasUpperBound(), | $multiplicity->getUpperBound(), | [])); -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure index 2724c52f0c5..381c28bc9b9 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure @@ -68,7 +68,7 @@ function meta::pure::changetoken::cast_generation::toMultiplicity(type: String[1 ))))); } -function <> meta::pure::changetoken::cast_generation::inlineJsonValue(json: JSONElement[1]): Code[1] +function meta::pure::changetoken::cast_generation::inlineJsonValue(json: JSONElement[1]): Code[1] { $json->match([ b: JSONBoolean[1] | j_boolean($b.value), diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure index d4817838de0..fdfdd0e4f53 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure @@ -37,7 +37,7 @@ function <> meta::pure::changetoken::diff_generation::getClasses $entities->packageClassesRecursive(); } -function <> meta::pure::changetoken::diff_generation::generateDiffFromVersionsAndClasses(versions: Versions[1], newClasses: Class[*], oldClasses: Class[*], propertyRenames: Map>[0..1], classRenames: Map[0..1], defaultValues: Map>[0..1], typeKeyName: String[1], versionKeyName: String[0..1]): Versions[1] +function meta::pure::changetoken::diff_generation::generateDiffFromVersionsAndClasses(versions: Versions[1], newClasses: Class[*], oldClasses: Class[*], propertyRenames: Map>[0..1], classRenames: Map[0..1], defaultValues: Map>[0..1], typeKeyName: String[1], versionKeyName: String[0..1]): Versions[1] { let prevVersion = if($versions.versions->size() > 0, | $versions.versions->at($versions.versions->size() - 1).version, | []); let version = ^Version( @@ -158,7 +158,7 @@ function <> meta::pure::changetoken::diff_generation::getAddFiel fieldName = $cp.second.name->toOne(), fieldType = stripVersionQualifier(printGenericType($cp.second.genericType)) + '[' + printMultiplicity($cp.second.multiplicity) + ']', safeCast = true, - defaultValue = ^ConstValue(value = lookupOrAny($defaultValues, stripPath($cp.first), $cp.second.name->toOne(), if($cp.second.defaultValue->isEmpty(), | generateDefault($cp.second, $typeKeyName, $versionKeyName), | $cp.second.defaultValue.functionDefinition->toOne()->cast(@Function<{->Any[*]}>)->eval()->serializeAny($cp.second, $typeKeyName, $versionKeyName)), $cp.second, $typeKeyName, $versionKeyName)) + defaultValue = ^ConstValue(value = lookupOrAny($defaultValues, stripPath($cp.first), $cp.second.name->toOne(), if($cp.second.defaultValue->isEmpty(), | generateDefault($cp.second, $typeKeyName, $versionKeyName), | $cp.second.defaultValue.functionDefinition.expressionSequence->evaluateAndDeactivate()->serializeAny($cp.second, $typeKeyName, $versionKeyName)), $cp.second, $typeKeyName, $versionKeyName)) )); } @@ -218,9 +218,19 @@ function <> meta::pure::changetoken::diff_generation::getRenamed ))); } -function <> meta::pure::changetoken::diff_generation::serializeAny(any: Any[*], property: Property[1], typeKeyName: String[1], versionKeyName: String[0..1]): JSONElement[1] +function <> meta::pure::changetoken::diff_generation::serializeAny(any: Any[*], property: Property[0..1], typeKeyName: String[1], versionKeyName: String[0..1]): JSONElement[1] { let values = $any->map(i | $i->match([ + i: InstanceValue[1] | serializeAny($i.values, [], $typeKeyName, $versionKeyName), + s: SimpleFunctionExpression[1] | $s.genericType.rawType->match([ + p: PrimitiveType[1] | if($s.functionName != 'minus', | fail('Not supported: ' + $s.functionName->toOne())->cast(@JSONElement), | serializeAny(minus($s.parametersValues->at(0)->cast(@InstanceValue).values->cast(@Number)), [], $typeKeyName, $versionKeyName)), + en: Enumeration[1] | if($s.functionName != 'extractEnumValue', | fail('Not supported: ' + $s.functionName->toOne())->cast(@JSONElement), | let e = $en->enumValues()->filter(v:Enum[1]| $v->id()==$s.parametersValues->at(1)->cast(@InstanceValue).values->cast(@String))->toOne()->cast(@Enum); ^JSONString(value = stripVersionQualifier($e->type()->toOne()->elementToPath() + '.' + $e->id()));), + c: Class[1] | if($s.functionName != 'new', | fail('Not supported: ' + $s.functionName->toOne())->cast(@JSONElement), | newJSONObject([newJSONKeyValue($typeKeyName, ^JSONString(value = stripVersionQualifier($c->elementToPath()->toString())))] + ->concatenate($s.parametersValues->at(2)->cast(@InstanceValue).values->cast(@KeyExpression)->map(x | newJSONKeyValue($x.key->cast(@InstanceValue).values->toOne()->toString(), serializeAny($x.expression, $c.properties->filter(p | $p.name == $x.key->cast(@InstanceValue).values->toOne()->toString())->toOne()->cast(@Property), $typeKeyName, $versionKeyName)))) + ->concatenate($c.properties->filter(p | $p.name != $versionKeyName) + ->filter(p | $s.parametersValues->at(2)->cast(@InstanceValue).values->cast(@KeyExpression)->map(x | $x.key->cast(@InstanceValue).values->toOne()->toString())->contains($p.name->toOne())->not()) + ->map(p | newJSONKeyValue($p.name->toOne(), generateDefault($p, $typeKeyName, $versionKeyName)))))); + ]), s: String[1] | ^JSONString(value = $s), d: Date[1] | ^JSONString(value = $d->toString()), d: DateTime[1] | ^JSONString(value = $d->toString()), @@ -235,7 +245,10 @@ function <> meta::pure::changetoken::diff_generation::serializeA l: List[1] | $l->expandValue($typeKeyName)->cast(@JSONArray).values, a: Any[1] | let c = $a->class(); newJSONObject([newJSONKeyValue($typeKeyName, ^JSONString(value = stripVersionQualifier($c->elementToPath()->toString())))]->concatenate($c.properties->filter(p | $p.name != $versionKeyName)->map(p | newJSONKeyValue($p.name->toOne(), serializeAny($p->eval($a), $p, $typeKeyName, $versionKeyName))))); ])); - if($property.multiplicity == PureOne || $property.multiplicity == PureZero || $property.multiplicity == ZeroOne, | if($property.multiplicity == PureZero || $property.multiplicity == ZeroOne && $values->size() == 0, | ^JSONNull(), | $values->toOne('Expecting one for property: ' + $property.name->toOne())), | ^JSONArray(values = $values)); + let ret = if($property != [], | if($property.multiplicity == PureOne || $property.multiplicity == PureZero || $property.multiplicity == ZeroOne, | if($property.multiplicity == PureZero || $property.multiplicity == ZeroOne && $values->size() == 0, | ^JSONNull(), | $values->toOne('Expecting one for property')), + | if($values->size() == 1 && $values->toOne()->instanceOf(JSONArray), | $values, | ^JSONArray(values = $values))), + | if($values->size() == 1, | $values->toOne(), | ^JSONArray(values = $values))); + $ret->toOne(); } function <> meta::pure::changetoken::diff_generation::generateDefault(property: Property[1], typeKeyName: String[1], versionKeyName: String[0..1]): JSONElement[1] diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/pom.xml b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/pom.xml new file mode 100644 index 00000000000..48287f37d4d --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/pom.xml @@ -0,0 +1,231 @@ + + + + + + org.finos.legend.engine + legend-engine-xts-changetoken + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-xt-changetoken-test-pure + jar + Legend Engine - XT - ChangeToken Test - PAR/JAVA + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + dependency-analyze + + + + junit:junit + + + + + + + org.finos.legend.pure + legend-pure-maven-generation-par + + src/main/resources + ${legend.pure.version} + + platform + core + core_external_language_java + core_pure_changetoken_test + + + ${project.basedir}/src/main/resources/core_pure_changetoken_test.definition.json + + + + + generate-sources + + build-pure-jar + + + + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + ${project.version} + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + org.finos.legend.engine + legend-engine-pure-functions-unclassified-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-pure-functions-javaCompiler-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-javaGeneration-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-javaPlatformBinding-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-changetoken-pure + ${project.version} + + + + + org.finos.legend.pure + legend-pure-maven-generation-java + + + compile + + build-pure-compiled-jar + + + true + true + modular + true + + core_pure_changetoken_test + + + + + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + ${project.version} + + + org.finos.legend.engine + legend-engine-pure-functions-javaCompiler-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-javaGeneration-pure + ${project.version} + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + org.finos.legend.engine + legend-engine-xt-changetoken-pure + ${project.version} + + + + + + + + + org.finos.legend.pure + legend-pure-m4 + + + org.finos.legend.pure + legend-pure-m3-core + + + org.finos.legend.pure + legend-pure-runtime-java-engine-compiled + + + + org.finos.legend.engine + legend-engine-pure-platform-java + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-unclassified + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler + test + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-json + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler + + + org.finos.legend.engine + legend-engine-pure-platform-dsl-store-java + runtime + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-shared-functions-json + + + org.finos.legend.engine + legend-engine-xt-javaGeneration-pure + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + + + org.eclipse.collections + eclipse-collections + + + org.eclipse.collections + eclipse-collections-api + + + + org.finos.legend.engine + legend-engine-xt-changetoken-pure + + + + junit + junit + + + diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/java/org/finos/legend/engine/changetoken/code/CorePureChangeTokenTestCodeRepositoryProvider.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/java/org/finos/legend/engine/changetoken/code/CorePureChangeTokenTestCodeRepositoryProvider.java new file mode 100644 index 00000000000..041e60e7ddd --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/java/org/finos/legend/engine/changetoken/code/CorePureChangeTokenTestCodeRepositoryProvider.java @@ -0,0 +1,28 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.changetoken.code; + +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepository; +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider; +import org.finos.legend.pure.m3.serialization.filesystem.repository.GenericCodeRepository; + +public class CorePureChangeTokenTestCodeRepositoryProvider implements CodeRepositoryProvider +{ + @Override + public CodeRepository repository() + { + return GenericCodeRepository.build("core_pure_changetoken_test.definition.json"); + } +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider new file mode 100644 index 00000000000..308292c05f8 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider @@ -0,0 +1 @@ +org.finos.legend.engine.changetoken.code.CorePureChangeTokenTestCodeRepositoryProvider \ No newline at end of file diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test.definition.json b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test.definition.json new file mode 100644 index 00000000000..fd4d6bfcc15 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test.definition.json @@ -0,0 +1,5 @@ +{ + "name" : "core_pure_changetoken_test", + "pattern" : "(meta::pure::changetoken)(::.*)?", + "dependencies" : ["core_pure_changetoken", "platform", "core_functions_unclassified", "core_functions_json", "core", "core_external_language_java", "core_external_language_java_compiler"] +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test.pure new file mode 100644 index 00000000000..ccfc01b291c --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test.pure @@ -0,0 +1,153 @@ +// Copyright 2024 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 meta::external::language::java::serialization::*; +import meta::external::language::java::compiler::*; +import meta::external::language::java::factory::*; +import meta::external::language::java::metamodel::project::*; +import meta::json::*; +import meta::pure::changetoken::*; +import meta::pure::changetoken::cast_generation::*; +import meta::pure::changetoken::tests::*; + +function <> meta::pure::changetoken::tests::testToMultiplicity(): Any[*] +{ + assertToMultiplicity('0', 0, 0, PureZero); + assertToMultiplicity('1', 1, 1, PureOne); + assertToMultiplicity('0..1', 0, 1, ZeroOne); + assertToMultiplicity('2', 2, 2, []); + assertToMultiplicity('2..2', 2, 2, []); + assertToMultiplicity('*', 0, [], ZeroMany); + assertToMultiplicity('0..*', 0, [], ZeroMany); + assertToMultiplicity('1..*', 1, [], OneMany); + assertToMultiplicity('2..4', 2, 4, []); + assertToMultiplicity('0..4', 0, 4, []); + assertToMultiplicity('5..*', 5, [], []); +} + +function <> meta::pure::changetoken::tests::assertToMultiplicity(input: String[1], min: Integer[1], max: Integer[0..1], expected: Multiplicity[0..1]): Boolean[1] +{ + let multiplicity = $input->toMultiplicity(); + assertEquals($min, $multiplicity->getLowerBound()); + assertEquals($max, if($multiplicity->hasUpperBound(), | $multiplicity->getUpperBound(), | [])); + if($expected != [], | assertEquals($expected, $multiplicity), | true); +} + +function <> meta::pure::changetoken::tests::testExtractTypeMultiplicity(): Any[*] +{ + assertExtractTypeMultiplicity('String[1]', 'String', 1, 1); + assertExtractTypeMultiplicity('Integer[*]', 'Integer', 0, []); + assertExtractTypeMultiplicity('Float[0..1]', 'Float', 0, 1); + assertExtractTypeMultiplicity('Decimal[10]', 'Decimal', 10, 10); +} + +function <> meta::pure::changetoken::tests::assertExtractTypeMultiplicity(input: String[1], type: String[1], min: Integer[1], max: Integer[0..1]): Boolean[1] +{ + let typeMultiplicity = $input->extractTypeMultiplicity(); + assertEquals($type, $typeMultiplicity.first); + let multiplicity = $typeMultiplicity.second; + assertEquals($min, $multiplicity->getLowerBound()); + assertEquals($max, if($multiplicity->hasUpperBound(), | $multiplicity->getUpperBound(), | [])); +} + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $json->setupSuiteFromJson('@type', 'version', true, false, true); +} + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1], alwaysStampAtRootVersion: Boolean[1], optionalStampAllVersions: Boolean[1], obsoleteJsonAsString: Boolean[1]): meta::external::language::java::metamodel::Class[1] +{ + $json->setupSuiteFromJson('@type', 'version', $alwaysStampAtRootVersion, $optionalStampAllVersions, $obsoleteJsonAsString); +} + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1], typeKeyName: String[1], versionKeyName: String[0..1]): meta::external::language::java::metamodel::Class[1] +{ + $json->setupSuiteFromJson($typeKeyName, $versionKeyName, true, false, true); +} + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1], typeKeyName: String[1], versionKeyName: String[0..1], alwaysStampAtRootVersion: Boolean[1], optionalStampAllVersions: Boolean[1], obsoleteJsonAsString: Boolean[1]): meta::external::language::java::metamodel::Class[1] +{ + $json->jsonToVersions($typeKeyName)->setupSuiteFromVersions($typeKeyName, $versionKeyName, $alwaysStampAtRootVersion, $optionalStampAllVersions, $obsoleteJsonAsString); +} + +function meta::pure::changetoken::tests::setupSuiteFromVersions(versions: Versions[1]): meta::external::language::java::metamodel::Class[1] +{ + $versions->setupSuiteFromVersions('@type', 'version', true, false, true); +} + +function meta::pure::changetoken::tests::setupSuiteFromVersions(versions: Versions[1], typeKeyName: String[1], versionKeyName: String[0..1], alwaysStampAtRootVersion: Boolean[1], optionalStampAllVersions: Boolean[1], obsoleteJsonAsString: Boolean[1]): meta::external::language::java::metamodel::Class[1] +{ + let project = generateCastFromVersions($alwaysStampAtRootVersion, $optionalStampAllVersions, $obsoleteJsonAsString, $typeKeyName, $versionKeyName, $versions, 'TestCast'); + let classes = allClasses($project); + $classes->toOne(); +} + +function meta::pure::changetoken::tests::upcast(class: meta::external::language::java::metamodel::Class[1], json: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('upcast', $json->parseJSON()->inlineJsonValue(), javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::upcast(class: meta::external::language::java::metamodel::Class[1], json: String[1], currentVersion: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('upcast', [$json->parseJSON()->inlineJsonValue(), j_string($currentVersion)], javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::downcast(class: meta::external::language::java::metamodel::Class[1], json: String[1], targetVersion: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('downcast', [$json->parseJSON()->inlineJsonValue(), j_string($targetVersion)], javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::downcast(class: meta::external::language::java::metamodel::Class[1], json: String[1], targetVersion: String[1], currentVersion: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('downcast', [$json->parseJSON()->inlineJsonValue(), j_string($targetVersion), j_string($currentVersion)], javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::versions(class: meta::external::language::java::metamodel::Class[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaList(javaString()), 'test', [], j_return($class->j_invoke('versions', [])))); +} + +function meta::pure::changetoken::tests::expect(class: meta::external::language::java::metamodel::Class[1], json: String[1]): Boolean[1] +{ + let ret = compileAndExecuteJava($class, ^CompilationConfiguration(classpath=[]), ^ExecutionConfiguration(class='org.finos.legend.engine.generated.meta.pure.changetoken.cast_generation.TestCast', method='test')); + assert($ret.compilationResult.errors->isEmpty(), | $ret.compilationResult.errors->joinStrings('expected no errors, got: \'', '\', \'', '\'')); + assert($ret.compilationResult.successful, | 'expected successful compilation'); + assert($ret.executionResult->toOne().error->isEmpty(), | 'expected no execution error, got: ' + $ret.executionResult->toOne().error->toOne()); + assert($ret.executionResult->toOne().successful, | 'expected successful execution'); + assert(!$ret.executionResult->isEmpty(), | 'expected non-empty execution result'); + let retJson = $ret.executionResult->toOne().returnValue->toOne()->toCompactJSONString(); + assert($retJson->parseJSON()->sort()->toCompactJSONString() == $json->parseJSON()->sort()->toCompactJSONString(), | 'unexpected return value, got: ' + $retJson); +} + +function meta::pure::changetoken::tests::exception(class: meta::external::language::java::metamodel::Class[1], error: String[1]): Boolean[1] +{ + let ret = compileAndExecuteJava($class, ^CompilationConfiguration(classpath=[]), ^ExecutionConfiguration(class='org.finos.legend.engine.generated.meta.pure.changetoken.cast_generation.TestCast', method='test')); + assert($ret.compilationResult.errors->isEmpty(), | $ret.compilationResult.errors->joinStrings('expected no errors, got: \'', '\', \'', '\'')); + assert($ret.compilationResult.successful, | 'expected successful compilation'); + assert($ret.executionResult->toOne().error->isEmpty()->not(), | 'expected execution error'); + assert($ret.executionResult->toOne().successful->not(), | 'expected not successful execution'); + assert(!$ret.executionResult->isEmpty(), | 'expected non-empty execution result'); + assert($ret.executionResult->toOne().returnValue->isEmpty(), | 'unexpected no return value, got: ' + $ret.executionResult->toOne().returnValue->toOne()->toString()); + assert($ret.executionResult->toOne().error->toOne()->toString()->contains($error), | 'expected execution error, got: ' + $ret.executionResult->toOne().error->toOne()->toString()); +} + +function <> meta::pure::changetoken::tests::toCompactJSONString(json:JavaValue[1]):String[1] +{ + $json->match([ + s:JavaObject[1] | if($s.class->in(['java.lang.Boolean', 'java.lang.Integer', 'java.lang.Double']), | $s.string, | '"' + $s.string->meta::json::escape() + '"'), + n:JavaNull[1] | 'null', + a:JavaIterable[1] | $a.values->map(v | $v->toCompactJSONString())->joinStrings('[', ',', ']'), + o:JavaMap[1] | $o.keyValuePairs->map(kv | $kv.first->toCompactJSONString() + ':' + $kv.second->toCompactJSONString())->joinStrings('{', ',', '}') + ]) +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test2.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test2.pure new file mode 100644 index 00000000000..0dbb6bf1c55 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test2.pure @@ -0,0 +1,100 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::test2::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::test2::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::CopyValue",\n' + + ' "source": {\n' + + ' "@type": "meta::pure::changetoken::RelativeFieldReference",\n' + + ' "path": "../existingValue"\n' + + ' }\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test2::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version": "ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'), + '{\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": "someValue"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test2::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": "someValue"\n' + + ' }\n' + + '}\n', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test3.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test3.pure new file mode 100644 index 00000000000..6fc94053a46 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test3.pure @@ -0,0 +1,107 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::test3::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::test3::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::ChangeFieldType",\n' + + ' "fieldName": "abc",\n' + + ' "oldFieldType": "Integer[1]",\n' + + ' "newFieldType": "String[1]",\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test3::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version": "ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'), + '{\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": "123"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test3::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": "123"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n', 'ftdm:abcdefg123'), + '{\n' + + ' "version": "ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test4.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test4.pure new file mode 100644 index 00000000000..749ed9979c1 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test4.pure @@ -0,0 +1,107 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::test4::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::test4::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::ChangeFieldType",\n' + + ' "fieldName": "abc",\n' + + ' "oldFieldType": "String[1]",\n' + + ' "newFieldType": "String[0..1]",\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test4::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version": "ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'), + '{\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test4::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": "123"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n', 'ftdm:abcdefg123'), + '{\n' + + ' "version": "ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SomeClassWithAnArray",\n' + + ' "array": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::tests::OuterClass",\n' + + ' "existingValue": "someValue",\n' + + ' "innerObject": {\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "abc": "123"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_boolean.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_boolean.pure new file mode 100644 index 00000000000..99c7b047b9b --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_boolean.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::boolean::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::boolean::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Boolean[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": true\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true}]\n' + + ' ],\n' + + ' "abc": true\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true}]\n' + + ' ],\n' + + ' "abc": true\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true}]\n' + + ' ],\n' + + ' "abc": false\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:false'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_boolean_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_boolean_string.pure new file mode 100644 index 00000000000..d313c88e144 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_boolean_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::boolean::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::boolean::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Boolean[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "true"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true}]\n' + + ' ],\n' + + ' "abc": true\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true}]\n' + + ' ],\n' + + ' "abc": true\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": true}]\n' + + ' ],\n' + + ' "abc": false\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:false'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_chain.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_chain.pure new file mode 100644 index 00000000000..8711de81ddd --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_chain.pure @@ -0,0 +1,131 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::chain::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::chain::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": 100\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg789",\n' + + ' "prevVersion": "ftdm:abcdefg456",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "def",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": 200\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::chain::testVersions(): Any[*] +{ + expect(setupSuite()->versions(), '["ftdm:abcdefg123", "ftdm:abcdefg456", "ftdm:abcdefg789"]'); +} + +function <> meta::pure::changetoken::tests::chain::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg789",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200}]\n' + + ' ],\n' + + ' "abc": 100, "def": 200\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::chain::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg789",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200}]\n' + + ' ],\n' + + ' "abc": 100, "def": 200\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::chain::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg789",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100, "def": 200}]\n' + + ' ],\n' + + ' "abc": 100, "def": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom.pure new file mode 100644 index 00000000000..43f0a51fd23 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::custom::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "{\\"@type\\":\\"Custom\\",\\"value\\":\\"0d\\"}"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"0d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"0d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"0d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, value=1d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_boolean.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_boolean.pure new file mode 100644 index 00000000000..0df7468107e --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_boolean.pure @@ -0,0 +1,108 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::array::boolean::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::boolean::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Boolean[*]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": [true]\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::boolean::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]}]\n' + + ' ],\n' + + ' "abc": [true]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::boolean::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]}]\n' + + ' ],\n' + + ' "abc": [true]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::boolean::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [true]}]\n' + + ' ],\n' + + ' "abc":[false]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[false]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_embedded.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_embedded.pure new file mode 100644 index 00000000000..4259d7eda95 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_embedded.pure @@ -0,0 +1,108 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::array::embedded::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::embedded::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[*]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "[1,2,3]"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::embedded::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]}]\n' + + ' ],\n' + + ' "abc": [1,2,3]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::embedded::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]}]\n' + + ' ],\n' + + ' "abc": [1,2,3]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::embedded::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]}]\n' + + ' ],\n' + + ' "abc":[5,6,7]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[5, 6, 7]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_float.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_float.pure new file mode 100644 index 00000000000..c5ae57211b3 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_float.pure @@ -0,0 +1,108 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::array::float::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::float::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Float[*]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": [1.2, 3.4]\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::float::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]}]\n' + + ' ],\n' + + ' "abc": [1.2, 3.4]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::float::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]}]\n' + + ' ],\n' + + ' "abc": [1.2, 3.4]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::float::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1.2, 3.4]}]\n' + + ' ],\n' + + ' "abc":[5.6, 7.8]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[5.6, 7.8]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_integer.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_integer.pure new file mode 100644 index 00000000000..d8548cee0f4 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_integer.pure @@ -0,0 +1,108 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::array::integer::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::integer::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[*]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": [1,2,3]\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::integer::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]}]\n' + + ' ],\n' + + ' "abc": [1,2,3]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::integer::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]}]\n' + + ' ],\n' + + ' "abc": [1,2,3]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::integer::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [1,2,3]}]\n' + + ' ],\n' + + ' "abc":[5,6,7]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[5, 6, 7]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_object.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_object.pure new file mode 100644 index 00000000000..4c53bc07b54 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_object.pure @@ -0,0 +1,113 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::array::object::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::object::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1..*]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": [\n' + + ' {\n' + + ' "@type": "Custom",\n' + + ' "value": 4.2\n' + + ' }\n' + + ' ]\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::object::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]}]\n' + + ' ],\n' + + ' "abc": [{"@type": "Custom","value": 4.2}]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::object::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]}]\n' + + ' ],\n' + + ' "abc": [{"@type": "Custom","value": 4.2}]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::object::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": [{"@type": "Custom","value": 4.2}]}]\n' + + ' ],\n' + + ' "abc":[{"@type": "Custom","value": 8.8}]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[{@type=Custom, value=8.8}]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_string.pure new file mode 100644 index 00000000000..9075b92381a --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_array_string.pure @@ -0,0 +1,111 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::array::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "String[1..*]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": [\n' + + ' "Foo",\n' + + ' "Bar"\n' + + ' ]\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]}]\n' + + ' ],\n' + + ' "abc": ["Foo", "Bar"]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]}]\n' + + ' ],\n' + + ' "abc": ["Foo", "Bar"]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": ["Foo", "Bar"]}]\n' + + ' ],\n' + + ' "abc":["Something","Else"]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[Something, Else]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_empty.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_empty.pure new file mode 100644 index 00000000000..22ac307d8b5 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_empty.pure @@ -0,0 +1,108 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::array::empty::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::empty::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[*]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": []\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::empty::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []}]\n' + + ' ],\n' + + ' "abc": []\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::empty::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []}]\n' + + ' ],\n' + + ' "abc": []\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::empty::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": []}]\n' + + ' ],\n' + + ' "abc": ["2023-06-22T18:30:01Z"]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[2023-06-22T18:30:01Z]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_map.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_map.pure new file mode 100644 index 00000000000..5b9fde22b0d --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_map.pure @@ -0,0 +1,83 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::map::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::map::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + let versions = meta::pure::changetoken::tests::getVersionsCustomMap(); + setupSuiteFromVersions($versions); +} + +function <> meta::pure::changetoken::tests::custom::map::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::map::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::map::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.0}, "value":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_nested.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_nested.pure new file mode 100644 index 00000000000..fe9fee61d4f --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_nested.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::custom::nested::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::nested::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.0}, "value":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_nested_no_escaping.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_nested_no_escaping.pure new file mode 100644 index 00000000000..f53aa1f2e2f --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_nested_no_escaping.pure @@ -0,0 +1,109 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::nested::no::escaping::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::nested::no::escaping::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', + true, false, false); +} + +function <> meta::pure::changetoken::tests::custom::nested::no::escaping::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"}]\n' + + ' ],\n' + + ' "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::no::escaping::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"}]\n' + + ' ],\n' + + ' "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::no::escaping::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "{\\"@type\\":\\"Custom\\",\\"restricted\\":true,\\"value\\":0,\\"range\\":{\\"@type\\":\\"intMinMax\\",\\"min\\":-1,\\"max\\":1,\\"round\\":0.5}}"}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.0}, "value":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null.pure new file mode 100644 index 00000000000..e6bb17872c2 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null.pure @@ -0,0 +1,107 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::null::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::null::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[0..1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": null\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null}]\n' + + ' ],\n' + + ' "abc": null\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ],\n' + + ' "abc": "2023-06-22T18:30:01Z"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null_keyword.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null_keyword.pure new file mode 100644 index 00000000000..194f5ba5eef --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null_keyword.pure @@ -0,0 +1,107 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::null::keyword::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::null::keyword::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[0..1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "null"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::keyword::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null}]\n' + + ' ],\n' + + ' "abc": null\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::keyword::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::keyword::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ],\n' + + ' "abc": "2023-06-22T18:30:01Z"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null_string.pure new file mode 100644 index 00000000000..1caac3032c9 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_null_string.pure @@ -0,0 +1,107 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::null::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::null::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[0..1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": ""\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": null}]\n' + + ' ],\n' + + ' "abc": null\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ],\n' + + ' "abc": "2023-06-22T18:30:01Z"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_object.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_object.pure new file mode 100644 index 00000000000..7485bf44fc6 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_object.pure @@ -0,0 +1,118 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::custom::object::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::object::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": {\n' + + ' "range": {\n' + + ' "min": -1,\n' + + ' "max": 1,\n' + + ' "@type": "intMinMax",\n' + + ' "round": 0.5\n' + + ' },\n' + + ' "@type": "Custom",\n' + + ' "restricted": true,\n' + + ' "value": 0\n' + + ' }\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}'); +} + +function <> meta::pure::changetoken::tests::custom::object::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.0}, "value":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_object_nested_version.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_object_nested_version.pure new file mode 100644 index 00000000000..32d1f195424 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_object_nested_version.pure @@ -0,0 +1,119 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::custom::object::nested::version::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::object::nested::version::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": {\n' + + ' "range": {\n' + + ' "min": -1,\n' + + ' "max": 1,\n' + + ' "@type": "intMinMax",\n' + + ' "round": 0.5\n' + + ' },\n' + + ' "@type": "Custom",\n' + + ' "restricted": true,\n' + + ' "value": 0\n' + + ' }\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', + true, true, true); +} + +function <> meta::pure::changetoken::tests::custom::object::nested::version::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg123"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg123"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg123"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::nested::version::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg123"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg123"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg123"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::nested::version::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "version":"ftdm:abcdefg456", "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.5}, "value":0}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "restricted":true, "range":{"min":-1, "max":1, "@type":"intMinMax", "round":0.0}, "value":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive.pure new file mode 100644 index 00000000000..ac17ea6e760 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::primitive::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::primitive::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "1970-01-01T00:00:01Z"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"}]\n' + + ' ],\n' + + ' "abc": "1970-01-01T00:00:01Z"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"}]\n' + + ' ],\n' + + ' "abc": "1970-01-01T00:00:01Z"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"}]\n' + + ' ],\n' + + ' "abc": "2023-06-22T18:30:01Z"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive_string.pure new file mode 100644 index 00000000000..239241770b7 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::primitive::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::primitive::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "\\"1970-01-01T00:00:01Z\\""\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"}]\n' + + ' ],\n' + + ' "abc": "1970-01-01T00:00:01Z"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"}]\n' + + ' ],\n' + + ' "abc": "1970-01-01T00:00:01Z"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "1970-01-01T00:00:01Z"}]\n' + + ' ],\n' + + ' "abc": "2023-06-22T18:30:01Z"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive_string_no_escaping.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive_string_no_escaping.pure new file mode 100644 index 00000000000..486cc3bef08 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_custom_primitive_string_no_escaping.pure @@ -0,0 +1,109 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::primitive::string::no::escaping::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::primitive::string::no::escaping::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Custom[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "\\"1970-01-01T00:00:01Z\\""\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', + true, false, false); +} + +function <> meta::pure::changetoken::tests::primitive::string::no::escaping::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""}]\n' + + ' ],\n' + + ' "abc": "\\"1970-01-01T00:00:01Z\\""\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::no::escaping::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""}]\n' + + ' ],\n' + + ' "abc": "\\"1970-01-01T00:00:01Z\\""\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::no::escaping::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "\\"1970-01-01T00:00:01Z\\""}]\n' + + ' ],\n' + + ' "abc": "2023-06-22T18:30:01Z"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_double.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_double.pure new file mode 100644 index 00000000000..b4f59beaded --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_double.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::double::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::double::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "double[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": 123.45\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45}]\n' + + ' ],\n' + + ' "abc": 123.45\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45}]\n' + + ' ],\n' + + ' "abc": 123.45\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45}]\n' + + ' ],\n' + + ' "abc": 67.89\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:67.89'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_double_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_double_string.pure new file mode 100644 index 00000000000..c36fdf01b35 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_double_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::double::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::double::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "double[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "123.45"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45}]\n' + + ' ],\n' + + ' "abc": 123.45\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45}]\n' + + ' ],\n' + + ' "abc": 123.45\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 123.45}]\n' + + ' ],\n' + + ' "abc": 67.89\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:67.89'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_from_json.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_from_json.pure new file mode 100644 index 00000000000..bf74dbecd4b --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_from_json.pure @@ -0,0 +1,130 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::from::json::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::from::json::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "safeCast": true,\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": 100\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_from_versions.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_from_versions.pure new file mode 100644 index 00000000000..8b464fd03d4 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_from_versions.pure @@ -0,0 +1,110 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::from::versions::*; +import meta::pure::changetoken::tests::*; +import meta::pure::changetoken::*; + +function meta::pure::changetoken::tests::from::versions::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + let abcdefg123 = ^Version(version='ftdm:abcdefg123'); + let value = ^ConstValue(value=100); + let addField = ^AddField(class='meta::pure::changetoken::tests::SampleClass', fieldName='abc', fieldType='Integer[1]', safeCast=true, defaultValue=$value); + let abcdefg456 = ^Version(version='ftdm:abcdefg456', prevVersion='ftdm:abcdefg123', changeTokens=$addField); + let versions = ^Versions(versions=[$abcdefg123, $abcdefg456]); + setupSuiteFromVersions($versions); +} + +function <> meta::pure::changetoken::tests::from::versions::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::versions::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::versions::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::versions::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_integer_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_integer_string.pure new file mode 100644 index 00000000000..599b741cb76 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_integer_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::integer::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::integer::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "100"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::integer::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::integer::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::integer::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move.pure new file mode 100644 index 00000000000..c4a3d4ee445 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move.pure @@ -0,0 +1,202 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::move::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::move::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "xyz",\n' + + ' "fieldType": "SampleNestedClass[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "{\\"@type\\":\\"SampleNestedClass\\",\\"step\\":0,\\"active\\":true}"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "abc"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "xyz",\n' + + ' "def"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"1d"}}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"2d"}}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"3d"}}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"4d"}}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0}, "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0}, "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0}, "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"SampleNestedClass", "active":true, "step":0}, "def": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"1d"}}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"2d"}}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"3d"}}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"SampleNestedClass", "active":true, "step":0, "def": {"@type":"Custom", "value":"4d"}}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move_extract.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move_extract.pure new file mode 100644 index 00000000000..0d472207075 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move_extract.pure @@ -0,0 +1,117 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::move::extract::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::move::extract::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "names",\n' + + ' "first"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "firstName"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "names",\n' + + ' "last"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "lastName"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RemoveField",\n' + + ' "fieldName": "names",\n' + + ' "fieldType": "NamesClass[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "{\\"@type\\":\\"NamesClass\\",\\"middle\\":\\"\\"}"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::extract::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "names": {"@type":"NamesClass", "first":"1d", "middle":"", "last":"2d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "names": {"@type":"NamesClass", "first":"3d", "middle":"", "last":"4d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "names": {"@type":"NamesClass", "first":"5d", "middle":"", "last":"6d"}}]\n' + + ' ],\n' + + ' "names": {"@type":"NamesClass", "first":"7d", "middle":"", "last":"8d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "firstName":"1d", "lastName":"2d"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "firstName":"3d", "lastName":"4d"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "firstName":"5d", "lastName":"6d"}]\n' + + ' ],\n' + + ' "firstName":"7d", "lastName":"8d"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::extract::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "firstName":"1d", "lastName":"2d"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "firstName":"3d", "lastName":"4d"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "firstName":"5d", "lastName":"6d"}]\n' + + ' ],\n' + + ' "firstName":"7d", "lastName":"8d"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "names": {"@type":"NamesClass", "first":"1d", "middle":"", "last":"2d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "names": {"@type":"NamesClass", "first":"3d", "middle":"", "last":"4d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "names": {"@type":"NamesClass", "first":"5d", "middle":"", "last":"6d"}}]\n' + + ' ],\n' + + ' "names": {"@type":"NamesClass", "first":"7d", "middle":"", "last":"8d"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move_nested.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move_nested.pure new file mode 100644 index 00000000000..0d6a6eb4d34 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_move_nested.pure @@ -0,0 +1,234 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::move::nested::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::move::nested::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "abc",\n' + + ' "value"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "xyz",\n' + + ' "value"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"1d"}, "xyz": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"2d"}, "xyz": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"3d"}, "xyz": {"@type":"String"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"String", "value":"4d"}, "xyz": {"@type":"String"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"1d"}, "abc": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"2d"}, "abc": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"3d"}, "abc": {"@type":"String"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"String", "value":"4d"}, "abc": {"@type":"String"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"1d"}, "abc": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"2d"}, "abc": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"3d"}, "abc": {"@type":"String"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"String", "value":"4d"}, "abc": {"@type":"String"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"1d"}, "xyz": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"2d"}, "xyz": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"3d"}, "xyz": {"@type":"String"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"String", "value":"4d"}, "xyz": {"@type":"String"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"1d"}, "xyz": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"2d"}, "xyz": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"3d"}, "xyz": {"@type":"String", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"String", "value":"4d"}, "xyz": {"@type":"String"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"1d"}, "abc": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"2d"}, "abc": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"3d"}, "abc": {"@type":"String"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"String", "value":"4d"}, "abc": {"@type":"String"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"1d"}, "abc": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"2d"}, "abc": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"3d"}, "abc": {"@type":"String", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"String", "value":"4d"}, "abc": {"@type":"String"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"1d"}, "xyz": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"2d"}, "xyz": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"3d"}, "xyz": {"@type":"String"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"String", "value":"4d"}, "xyz": {"@type":"String"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"1d"}, "xyz": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"2d"}, "xyz": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"3d"}, "xyz": {"@type":"String", "value":"5d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"String", "value":"4d"}, "xyz": {"@type":"String"}\n' + + '}'), + 'Cannot overwrite with different value:5d'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"1d"}, "abc": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"2d"}, "abc": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"3d"}, "abc": {"@type":"String", "value":"6d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"String", "value":"4d"}, "abc": {"@type":"String"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:6d'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastInvalidDestination(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"1d"}, "xyz": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"2d"}, "xyz": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"3d"}, "xyz": "invalid"}]\n' + + ' ],\n' + + ' "abc": {"@type":"String", "value":"4d"}, "xyz": {"@type":"String"}\n' + + '}'), + 'Destination is not a map: xyz'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastInvalidDestination(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"1d"}, "abc": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"2d"}, "abc": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"3d"}, "abc": "invalid"}]\n' + + ' ],\n' + + ' "xyz": {"@type":"String", "value":"4d"}, "abc": {"@type":"String"}\n' + + '}', 'ftdm:abcdefg123'), + 'Destination is not a map: abc'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastInvalidSource(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"1d"}, "xyz": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"String", "value":"2d"}, "xyz": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "invalid", "xyz": {"@type":"String"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"String", "value":"4d"}, "xyz": {"@type":"String"}\n' + + '}'), + 'Source is not a map: abc'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastInvalidSource(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"1d"}, "abc": {"@type":"String"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"String", "value":"2d"}, "abc": {"@type":"String"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": "invalid", "abc": {"@type":"String"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"String", "value":"4d"}, "abc": {"@type":"String"}\n' + + '}', 'ftdm:abcdefg123'), + 'Source is not a map: xyz'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_remove.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_remove.pure new file mode 100644 index 00000000000..72e1d4a9372 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_remove.pure @@ -0,0 +1,130 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::remove::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::remove::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RemoveField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": 100\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::remove::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::remove::testUpcastNull(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::remove::testUpcastNonDefault(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 300\n' + + '}'), + 'Cannot remove non-default value:300'); +} + +function <> meta::pure::changetoken::tests::remove::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename.pure new file mode 100644 index 00000000000..728adbcd20a --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename.pure @@ -0,0 +1,268 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::rename::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "abc"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "xyz"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}, "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}, "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}, "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}, "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d"}, "xyz": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d"}, "xyz": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d"}, "xyz": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}, "xyz": {"@type":"Custom", "value":"8d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}, "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}, "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}, "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}, "xyz": {"@type":"Custom", "value":"9d"}\n' + + '}'), + 'Cannot overwrite with different value:{@type=Custom, value=9d}'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d"}, "xyz": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d"}, "xyz": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d"}, "xyz": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}, "xyz": {"@type":"Custom", "value":"9d"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:{@type=Custom, value=8d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_field_renamed_class.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_field_renamed_class.pure new file mode 100644 index 00000000000..daa4fd53280 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_field_renamed_class.pure @@ -0,0 +1,273 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::rename::field::renamed::class::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::field::renamed::class::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "abc"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "xyz"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenamedClass",\n' + + ' "newName": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}, "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}, "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}, "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}, "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"5d"}, "xyz": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"6d"}, "xyz": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"7d"}, "xyz": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}, "xyz": {"@type":"Custom", "value":"8d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}, "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}, "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}, "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}, "xyz": {"@type":"Custom", "value":"9d"}\n' + + '}'), + 'Cannot overwrite with different value:{@type=Custom, value=9d}'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"5d"}, "xyz": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"6d"}, "xyz": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"7d"}, "xyz": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}, "xyz": {"@type":"Custom", "value":"9d"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:{@type=Custom, value=8d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_nested_property.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_nested_property.pure new file mode 100644 index 00000000000..b1db7beb9e4 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_nested_property.pure @@ -0,0 +1,270 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::rename::nested::property::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::nested::property::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "abc",\n' + + ' "value"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "abc",\n' + + ' "valueCustom"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "valueCustom":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"OtherCustom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"OtherCustom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "valueOther":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "valueOther":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"2d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "valueCustom":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"2d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"OtherCustom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"2d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"OtherCustom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d", "valueCustom":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "valueCustom":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d", "valueCustom":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d", "valueCustom":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d", "valueCustom":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d", "valueCustom":"8d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d", "valueCustom":"9d"}\n' + + '}'), + 'Cannot overwrite with different value:9d'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d", "valueCustom":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d", "valueCustom":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d", "valueCustom":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d", "valueCustom":"9d"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:8d'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_property.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_property.pure new file mode 100644 index 00000000000..5ace82b87db --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_rename_property.pure @@ -0,0 +1,268 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::rename::property::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::property::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "value"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "valueCustom"\n' + + ' ],\n' + + ' "class": "Custom"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "valueCustom":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"OtherCustom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"OtherCustom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"OtherCustom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "valueOther":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "valueOther":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "valueCustom":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "valueCustom":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "valueCustom":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "valueCustom":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"OtherCustom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"OtherCustom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"OtherCustom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"OtherCustom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"OtherCustom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"OtherCustom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"OtherCustom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"OtherCustom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "valueOther":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d", "valueCustom":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "valueCustom":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d", "valueCustom":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d", "valueCustom":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d", "valueCustom":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d", "valueCustom":"8d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d", "valueCustom":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d", "valueCustom":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d", "valueCustom":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d", "valueCustom":"9d"}\n' + + '}'), + 'Cannot overwrite with different value:9d'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d", "valueCustom":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d", "valueCustom":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d", "valueCustom":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d", "valueCustom":"9d"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:8d'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_renamed_class.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_renamed_class.pure new file mode 100644 index 00000000000..a62109645a4 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_renamed_class.pure @@ -0,0 +1,137 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::renamed::class::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::renamed::class::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenamedClass",\n' + + ' "newName": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_renamed_class_rename_field.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_renamed_class_rename_field.pure new file mode 100644 index 00000000000..c7e759192c2 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_renamed_class_rename_field.pure @@ -0,0 +1,273 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::renamed::class::rename::field::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::renamed::class::rename::field::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenamedClass",\n' + + ' "newName": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::RenameField",\n' + + ' "oldFieldName": [\n' + + ' "abc"\n' + + ' ],\n' + + ' "newFieldName": [\n' + + ' "xyz"\n' + + ' ],\n' + + ' "class": "meta::pure::changetoken::tests::nested::NewSampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "abc": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::OtherClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::OtherClass", "xyz": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"4d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"3d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "def": {"@type":"Custom", "value":"2d"}}]\n' + + ' ],\n' + + ' "def": {"@type":"Custom", "value":"1d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}, "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}, "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}, "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}, "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "xyz": {"@type":"Custom", "value":"4d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"5d"}, "xyz": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"6d"}, "xyz": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"7d"}, "xyz": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}, "xyz": {"@type":"Custom", "value":"8d"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"1d"}, "xyz": {"@type":"Custom", "value":"1d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"2d"}, "xyz": {"@type":"Custom", "value":"2d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": {"@type":"Custom", "value":"3d"}, "xyz": {"@type":"Custom", "value":"3d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"4d"}, "xyz": {"@type":"Custom", "value":"9d"}\n' + + '}'), + 'Cannot overwrite with different value:{@type=Custom, value=9d}'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::nested::NewSampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"5d"}, "xyz": {"@type":"Custom", "value":"5d"}},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"6d"}, "xyz": {"@type":"Custom", "value":"6d"}},\n' + + ' [{"@type": "meta::pure::changetoken::tests::nested::NewSampleClass", "abc": {"@type":"Custom", "value":"7d"}, "xyz": {"@type":"Custom", "value":"7d"}}]\n' + + ' ],\n' + + ' "abc": {"@type":"Custom", "value":"8d"}, "xyz": {"@type":"Custom", "value":"9d"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:{@type=Custom, value=8d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_string.pure new file mode 100644 index 00000000000..20cf0aab5a2 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "String[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "one \\" two"\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"}]\n' + + ' ],\n' + + ' "abc": "one \\" two"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"}]\n' + + ' ],\n' + + ' "abc": "one \\" two"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"}]\n' + + ' ],\n' + + ' "abc": "two \\" one"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:two " one'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_string_quotes.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_string_quotes.pure new file mode 100644 index 00000000000..c016a20e79d --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_string_quotes.pure @@ -0,0 +1,108 @@ +// Copyright 2023 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 meta::pure::changetoken::tests::string::quotes::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::string::quotes::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "String[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": "\\"one \\\\\\" two\\""\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::quotes::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"}]\n' + + ' ],\n' + + ' "abc": "one \\" two"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::quotes::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"}]\n' + + ' ],\n' + + ' "abc": "one \\" two"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "version":"ftdm:abcdefg123", \n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::quotes::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "version":"ftdm:abcdefg456",\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": "one \\" two"}]\n' + + ' ],\n' + + ' "abc": "two \\" one"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:two " one'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_version_custom.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_version_custom.pure new file mode 100644 index 00000000000..1cdd8f74c8f --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_version_custom.pure @@ -0,0 +1,130 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::version::custom::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::version::custom::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "$type$": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "$type$": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "$type$": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "$type$": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "defaultValue": {\n' + + ' "$type$": "meta::pure::changetoken::ConstValue",\n' + + ' "value": 100\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', '$type$', '$version$'); +} + +function <> meta::pure::changetoken::tests::version::custom::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "$version$":"ftdm:abcdefg123", \n' + + ' "$type$": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"$type$": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"$type$": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"$type$": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' "$version$":"ftdm:abcdefg456",\n' + + ' "$type$": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::version::custom::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "$version$":"ftdm:abcdefg456",\n' + + ' "$type$": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "$version$":"ftdm:abcdefg123", \n' + + ' "$type$": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"$type$": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"$type$": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"$type$": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::version::custom::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "$version$":"ftdm:abcdefg456",\n' + + ' "$type$": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"$type$": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"$type$": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"$type$": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "$version$":"ftdm:abcdefg123", \n' + + ' "$type$": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"$type$": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"$type$": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"$type$": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::version::custom::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "$version$":"ftdm:abcdefg456",\n' + + ' "$type$": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"$type$": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_version_null.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_version_null.pure new file mode 100644 index 00000000000..92ea58c6e20 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/cast_generation_test_version_null.pure @@ -0,0 +1,123 @@ +// Copyright 2024 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 meta::pure::changetoken::tests::null::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::null::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' "@type": "meta::pure::changetoken::Versions",\n' + + ' "versions": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg123"\n' + + ' },\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::Version",\n' + + ' "version": "ftdm:abcdefg456",\n' + + ' "prevVersion": "ftdm:abcdefg123",\n' + + ' "changeTokens": [\n' + + ' {\n' + + ' "@type": "meta::pure::changetoken::AddField",\n' + + ' "fieldName": "abc",\n' + + ' "fieldType": "Integer[1]",\n' + + ' "defaultValue": {\n' + + ' "@type": "meta::pure::changetoken::ConstValue",\n' + + ' "value": 100\n' + + ' },\n' + + ' "safeCast": true,\n' + + ' "class": "meta::pure::changetoken::tests::SampleClass"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', '@type', []); +} + +function <> meta::pure::changetoken::tests::null::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::null::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 100\n' + + '}', 'ftdm:abcdefg123', 'ftdm:abcdefg456'), + '{\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::null::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123', 'ftdm:abcdefg456'), + '{\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass"},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass"}, \n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::null::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' "@type": "meta::pure::changetoken::tests::SampleClass",\n' + + ' "innerObject": {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' "innerNestedArray":[\n' + + ' {"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100},\n' + + ' [{"@type": "meta::pure::changetoken::tests::SampleClass", "abc": 100}]\n' + + ' ],\n' + + ' "abc": 300\n' + + '}', 'ftdm:abcdefg123', 'ftdm:abcdefg456'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/changetoken_test.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/changetoken_test.pure similarity index 97% rename from legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/changetoken_test.pure rename to legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/changetoken_test.pure index 42cc5d71f44..bdff5301665 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/changetoken_test.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/changetoken_test.pure @@ -49,7 +49,7 @@ Class <> meta::pure::changetoken::tests::SampleClass } // This is test Versions: AddField with ConstValue(^Map()->put('@type', 'Custom')->put('restricted', true)->put('value', 0)->put('range', ^Map()->put('@type', 'intMinMax')->put('min', -1)->put('max', 1)->put('round', 0.5))) -function <> meta::pure::changetoken::tests::getVersionsCustomMap():Versions[1] +function meta::pure::changetoken::tests::getVersionsCustomMap():Versions[1] { ^Versions( versions=[ diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation_test.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/diff_generation_test.pure similarity index 88% rename from legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation_test.pure rename to legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/diff_generation_test.pure index 462c89224e3..75ed05ec294 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation_test.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/main/resources/core_pure_changetoken_test/diff_generation_test.pure @@ -14,13 +14,14 @@ import meta::json::*; import meta::pure::changetoken::*; +import meta::pure::changetoken::cast_generation::*; import meta::pure::changetoken::diff_generation::*; import meta::pure::changetoken::tests::*; Class <> meta::pure::changetoken::tests::new::entities::vX_X_X::SampleClass { abc : String[1] = 'UNKNOWN'; - def : meta::pure::changetoken::tests::new::dependencies::vX_X_X::NestedClass[1] = ^meta::pure::changetoken::tests::new::dependencies::vX_X_X::NestedClass(one = 'TWO', three = 4.5, four = meta::pure::changetoken::tests::new::entities::vX_X_X::SampleEnum.D); + def : meta::pure::changetoken::tests::new::dependencies::vX_X_X::NestedClass[1] = ^meta::pure::changetoken::tests::new::dependencies::vX_X_X::NestedClass(one = 'TWO', three = -4.5, four = meta::pure::changetoken::tests::new::entities::vX_X_X::SampleEnum.D); ghi: Boolean[1] = true; jkl: Number[1] = 1.1; mno: Integer[1] = 1; @@ -51,7 +52,7 @@ function <> meta::pure::changetoken::tests::testAddFieldWithDefaultVa let changeTokens = $newVersion.changeTokens; assertAddedClass($changeTokens, 0, 'meta::pure::changetoken::tests::SampleClass'); assertAddField($changeTokens, 1, 'meta::pure::changetoken::tests::SampleClass', 'abc', 'String[1]', true, '"UNKNOWN"'); - assertAddField($changeTokens, 2, 'meta::pure::changetoken::tests::SampleClass', 'def', 'meta::pure::changetoken::tests::NestedClass[1]', true, '{"one":"TWO","@type":"meta::pure::changetoken::tests::NestedClass","three":4.5,"four":"meta::pure::changetoken::tests::SampleEnum.D","five":null,"six":[]}'); + assertAddField($changeTokens, 2, 'meta::pure::changetoken::tests::SampleClass', 'def', 'meta::pure::changetoken::tests::NestedClass[1]', true, '{"one":"TWO","@type":"meta::pure::changetoken::tests::NestedClass","three":-4.5,"four":"meta::pure::changetoken::tests::SampleEnum.D","five":null,"six":[]}'); assertAddField($changeTokens, 3, 'meta::pure::changetoken::tests::SampleClass', 'ghi', 'Boolean[1]', true, 'true'); assertAddField($changeTokens, 4, 'meta::pure::changetoken::tests::SampleClass', 'jkl', 'Number[1]', true, '1.1'); assertAddField($changeTokens, 5, 'meta::pure::changetoken::tests::SampleClass', 'mno', 'Integer[1]', true, '1'); @@ -274,3 +275,16 @@ function <> meta::pure::changetoken::tests::testGetTokens(): Boolean[ let tokens = getHashTokens($classes, 'version'); assertEquals(['meta::pure::changetoken::tests::OldSampleClass', 'xyz', 'String[1]'], $tokens); } + +function <> meta::pure::changetoken::tests::testInterpreted(): Boolean[1] +{ + let oldScope = []; + let newScope = meta::legend::compileLegendGrammar('Class xxx::new::entities::vX_X_X::XXX{abc : String[1] = \'UNKNOWN\';} Class xxx::new::entities::vX_X_X::YYY{def : xxx::new::entities::vX_X_X::XXX[1] = ^xxx::new::entities::vX_X_X::XXX(abc=\'INVALID\'); ghi : xxx::new::entities::vX_X_X::XXX[1];}')->cast(@Class); + let oldVersions = ^Versions(versions = [^Version(version = 'da39a3ee5e6b4b0d3255bfef95601890afd80709')]); + let newVersions = $oldVersions->generateDiffFromVersionsAndClasses($newScope, $oldScope, [], [], [], '@type', 'version'); + let jsonVersions = $newVersions->versionsToJson('@type'); + let expectedJson = '{"@type":"meta::pure::changetoken::Versions","versions":[{"@type":"meta::pure::changetoken::Version","version":"da39a3ee5e6b4b0d3255bfef95601890afd80709"},{"@type":"meta::pure::changetoken::Version","changeTokens":[{"@type":"meta::pure::changetoken::AddedClass","class":"xxx::XXX"},{"@type":"meta::pure::changetoken::AddField","class":"xxx::XXX","defaultValue":{"@type":"meta::pure::changetoken::ConstValue","value":"UNKNOWN"},"fieldName":"abc","fieldType":"String[1]","safeCast":true},{"@type":"meta::pure::changetoken::AddedClass","class":"xxx::YYY"},{"@type":"meta::pure::changetoken::AddField","class":"xxx::YYY","defaultValue":{"@type":"meta::pure::changetoken::ConstValue","value":{"@type":"xxx::XXX","abc":"INVALID"}},"fieldName":"def","fieldType":"xxx::XXX[1]","safeCast":true},{"@type":"meta::pure::changetoken::AddField","class":"xxx::YYY","defaultValue":{"@type":"meta::pure::changetoken::ConstValue","value":{"@type":"xxx::XXX","abc":""}},"fieldName":"ghi","fieldType":"xxx::XXX[1]","safeCast":true}],"prevVersion":"da39a3ee5e6b4b0d3255bfef95601890afd80709","version":"65896f85895f1305e1c69d233118d0da1402ee4d"}]}'; + assertEquals($expectedJson->parseJSON()->sort()->toCompactJSONString(), $jsonVersions->parseJSON()->sort()->toCompactJSONString()); + let class = setupSuiteFromVersions($newVersions)->upcast('{"version":"da39a3ee5e6b4b0d3255bfef95601890afd80709","@type":"xxx::XXX"}'); + $class->expect('{"version":"65896f85895f1305e1c69d233118d0da1402ee4d","@type":"xxx::XXX","abc":"UNKNOWN"}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/test/java/org/finos/legend/engine/changetoken/test/Test_Pure_Suite.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/test/java/org/finos/legend/engine/changetoken/test/Test_Pure_Suite.java new file mode 100644 index 00000000000..57c2a841055 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-test-pure/src/test/java/org/finos/legend/engine/changetoken/test/Test_Pure_Suite.java @@ -0,0 +1,32 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.changetoken.test; + +import junit.framework.TestSuite; +import org.finos.legend.pure.m3.execution.test.PureTestBuilder; +import org.finos.legend.pure.m3.execution.test.TestCollection; +import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport; +import org.finos.legend.pure.runtime.java.compiled.testHelper.PureTestBuilderCompiled; + +public class Test_Pure_Suite +{ + public static TestSuite suite() + { + CompiledExecutionSupport executionSupport = PureTestBuilderCompiled.getClassLoaderExecutionSupport(); + TestSuite suite = new TestSuite(); + suite.addTest(PureTestBuilderCompiled.buildSuite(TestCollection.collectTests("meta::pure::changetoken", executionSupport.getProcessorSupport(), ci -> PureTestBuilder.satisfiesConditions(ci, executionSupport.getProcessorSupport())), executionSupport)); + return suite; + } +} diff --git a/legend-engine-xts-changetoken/pom.xml b/legend-engine-xts-changetoken/pom.xml index 4ed4ead9131..95b59f96661 100644 --- a/legend-engine-xts-changetoken/pom.xml +++ b/legend-engine-xts-changetoken/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -31,5 +31,6 @@ legend-engine-xt-changetoken-compiler legend-engine-xt-changetoken-pure + legend-engine-xt-changetoken-test-pure \ No newline at end of file diff --git a/legend-engine-xts-daml/legend-engine-xt-daml-grammar/pom.xml b/legend-engine-xts-daml/legend-engine-xt-daml-grammar/pom.xml index a3fc0fe1ae6..992d34847d4 100644 --- a/legend-engine-xts-daml/legend-engine-xt-daml-grammar/pom.xml +++ b/legend-engine-xts-daml/legend-engine-xt-daml-grammar/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-daml org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-daml/legend-engine-xt-daml-http-api/pom.xml b/legend-engine-xts-daml/legend-engine-xt-daml-http-api/pom.xml index 3e416c9de79..104f5a87c78 100644 --- a/legend-engine-xts-daml/legend-engine-xt-daml-http-api/pom.xml +++ b/legend-engine-xts-daml/legend-engine-xt-daml-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-daml - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-daml-http-api diff --git a/legend-engine-xts-daml/legend-engine-xt-daml-model/pom.xml b/legend-engine-xts-daml/legend-engine-xt-daml-model/pom.xml index c4b568eade5..e6dc71920f5 100644 --- a/legend-engine-xts-daml/legend-engine-xt-daml-model/pom.xml +++ b/legend-engine-xts-daml/legend-engine-xt-daml-model/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-daml org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-daml/legend-engine-xt-daml-pure/pom.xml b/legend-engine-xts-daml/legend-engine-xt-daml-pure/pom.xml index 87473fd088c..0a983a7e77f 100644 --- a/legend-engine-xts-daml/legend-engine-xt-daml-pure/pom.xml +++ b/legend-engine-xts-daml/legend-engine-xt-daml-pure/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-daml org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-daml/pom.xml b/legend-engine-xts-daml/pom.xml index 5ca418180bd..fceddae569e 100644 --- a/legend-engine-xts-daml/pom.xml +++ b/legend-engine-xts-daml/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/pom.xml b/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/pom.xml index a551c89361b..fff3ca664bf 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/pom.xml +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-data-space org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataSpaceCompilerExtension.java b/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataSpaceCompilerExtension.java index 7fe65520255..4bb63a5f980 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataSpaceCompilerExtension.java +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataSpaceCompilerExtension.java @@ -98,7 +98,7 @@ public Iterable> getExtraProcessors() { return Collections.singletonList(Processor.newProcessor( DataSpace.class, - Lists.fixedSize.with(PackageableRuntime.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.class, Diagram.class), + Lists.fixedSize.with(PackageableRuntime.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.class, Diagram.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function.class), (dataSpace, context) -> { Root_meta_pure_metamodel_dataSpace_DataSpace metamodel = new Root_meta_pure_metamodel_dataSpace_DataSpace_Impl(dataSpace.name, null, context.pureModel.getClass("meta::pure::metamodel::dataSpace::DataSpace"))._name(dataSpace.name); @@ -151,14 +151,6 @@ public Iterable> getExtraProcessors() Root_meta_pure_data_EmbeddedData data = Objects.isNull(executionContext.testData) ? null : executionContext.testData.accept(new EmbeddedDataFirstPassBuilder(context, new ProcessingContext("Dataspace '" + metamodel._name() + "' Second Pass"))); dataSpaceExecutionContextIndex.get(executionContext.name)._testData(data); }); - }, - (dataSpace, context) -> - { - - }, - (dataSpace, context) -> - { - }, (dataSpace, context) -> { @@ -300,12 +292,7 @@ else if (dataSpace.supportInfo instanceof DataSpaceSupportCombinedInfo) } metamodel._supportInfo(supportInfo); } - }, - (dataSpace, context) -> - { - // Move checking mapping/runtime utilized in the function within the curated template query does not align with the mapping/runtime applied in the execution context - // to the sixth pass because function body and parameter are processed in the fifthPassBuilder (see https://github.com/finos/legend-engine/pull/2918) - // if we do the checking in the fifth pass, function body and parameter will be an empty list + if (dataSpace.executables != null) { dataSpace.executables.forEach(executable -> diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-generation/pom.xml b/legend-engine-xts-data-space/legend-engine-xt-data-space-generation/pom.xml index 899bd8a586d..642dca06525 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-generation/pom.xml +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-data-space - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-grammar/pom.xml b/legend-engine-xts-data-space/legend-engine-xt-data-space-grammar/pom.xml index 8788b94417e..c48180404d4 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-grammar/pom.xml +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-grammar/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-data-space - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-http-api/pom.xml b/legend-engine-xts-data-space/legend-engine-xt-data-space-http-api/pom.xml index c25fddc7b23..5ad785c7a14 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-http-api/pom.xml +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-data-space - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-protocol/pom.xml b/legend-engine-xts-data-space/legend-engine-xt-data-space-protocol/pom.xml index 25ac9abd992..07956f124a8 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-protocol/pom.xml +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-data-space - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-pure-metamodel/pom.xml b/legend-engine-xts-data-space/legend-engine-xt-data-space-pure-metamodel/pom.xml index dec3e6bf6dd..ece75e91b51 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-pure-metamodel/pom.xml +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-pure-metamodel/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-data-space - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/legend-engine-xt-data-space-pure/pom.xml b/legend-engine-xts-data-space/legend-engine-xt-data-space-pure/pom.xml index d7e1e2287b8..b25f25d258f 100644 --- a/legend-engine-xts-data-space/legend-engine-xt-data-space-pure/pom.xml +++ b/legend-engine-xts-data-space/legend-engine-xt-data-space-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-data-space - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-data-space/pom.xml b/legend-engine-xts-data-space/pom.xml index 0d2011a0aea..2dea2be2cc2 100644 --- a/legend-engine-xts-data-space/pom.xml +++ b/legend-engine-xts-data-space/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/pom.xml b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/pom.xml index a3398cbe96f..86697557a01 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/pom.xml +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-dataquality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -271,6 +271,12 @@ h2 test + + org.finos.legend.engine + legend-engine-language-pure-grammar + test + test-jar + diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/main/java/org/finos/legend/engine/language/dataquality/api/DataQualityExecute.java b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/main/java/org/finos/legend/engine/language/dataquality/api/DataQualityExecute.java index 056a70608c2..2030175ce9d 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/main/java/org/finos/legend/engine/language/dataquality/api/DataQualityExecute.java +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/main/java/org/finos/legend/engine/language/dataquality/api/DataQualityExecute.java @@ -118,7 +118,7 @@ public Response generatePlan(DataQualityExecuteTrialInput dataQualityExecuteInpu // 1. load pure model from PureModelContext PureModel pureModel = this.modelManager.loadModel(dataQualityExecuteInput.model, dataQualityExecuteInput.clientVersion, identity, null); // 2. call DQ PURE func to generate lambda - LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambda(pureModel, dataQualityExecuteInput.packagePath); + LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambda(pureModel, dataQualityExecuteInput.packagePath, this.extensions); // 3. Generate Plan from the lambda generated in the previous step SingleExecutionPlan singleExecutionPlan = PlanGenerator.generateExecutionPlan(dqLambdaFunction, null, null, null, pureModel, dataQualityExecuteInput.clientVersion, PlanPlatform.JAVA, null, this.extensions.apply(pureModel), this.transformers);// since lambda has from function we dont need mapping, runtime and context LOGGER.info(new LogInfo(identity.getName(), DataQualityExecutionLoggingEventType.DATAQUALITY_GENERATE_PLAN_END, System.currentTimeMillis() - start).toString()); @@ -146,7 +146,7 @@ public Response execute(@Context HttpServletRequest request, DataQualityExecuteT // 1. load pure model from PureModelContext PureModel pureModel = this.modelManager.loadModel(dataQualityExecuteInput.model, dataQualityExecuteInput.clientVersion, identity, null); // 2. call DQ PURE func to generate lambda - LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambdaForTrial(pureModel, dataQualityExecuteInput.packagePath, dataQualityExecuteInput.queryLimit); + LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambdaForTrial(pureModel, dataQualityExecuteInput.packagePath, dataQualityExecuteInput.queryLimit, this.extensions); // 3. Generate Plan from the lambda generated in the previous step SingleExecutionPlan singleExecutionPlan = PlanGenerator.generateExecutionPlan(dqLambdaFunction, null, null, null, pureModel, dataQualityExecuteInput.clientVersion, PlanPlatform.JAVA, null, this.extensions.apply(pureModel), this.transformers);// since lambda has from function we dont need mapping, runtime and context // 4. execute plan @@ -176,7 +176,7 @@ public Response lambda(@Context HttpServletRequest request, DataQualityExecuteTr // 1. load pure model from PureModelContext PureModel pureModel = this.modelManager.loadModel(dataQualityExecuteInput.model, dataQualityExecuteInput.clientVersion, identity, null); // 2. call DQ PURE func to generate lambda - LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambdaForTrial(pureModel, dataQualityExecuteInput.packagePath, dataQualityExecuteInput.queryLimit); + LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambdaForTrial(pureModel, dataQualityExecuteInput.packagePath, dataQualityExecuteInput.queryLimit, this.extensions); Lambda lambda = DataQualityLambdaGenerator.transformLambda(dqLambdaFunction, pureModel, this.extensions); return ManageConstantResult.manageResult(identity.getName(), lambda, objectMapper); } diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/java/org/finos/legend/engine/language/dataquality/api/TestDataQualityApi.java b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/java/org/finos/legend/engine/language/dataquality/api/TestDataQualityApi.java index 48c3106bb85..599ed3c018f 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/java/org/finos/legend/engine/language/dataquality/api/TestDataQualityApi.java +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/java/org/finos/legend/engine/language/dataquality/api/TestDataQualityApi.java @@ -18,6 +18,7 @@ import org.finos.legend.engine.language.pure.compiler.Compiler; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtensionLoader; +import org.finos.legend.engine.language.pure.grammar.test.GrammarParseTestUtils; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.graph.RootGraphFetchTree; import org.finos.legend.engine.shared.core.ObjectMapperFactory; @@ -42,8 +43,7 @@ public class TestDataQualityApi @Test public void testDataQualityGetPropertyPathTree() throws IOException { - URL url = Objects.requireNonNull(getClass().getClassLoader().getResource("inputs/modelWithDataQualityValidation.json")); - PureModelContextData pureModelContextData = objectMapper.readValue(url, PureModelContextData.class); + PureModelContextData pureModelContextData = GrammarParseTestUtils.loadPureModelContextFromResource("inputs/modelWithDataQualityValidation.pure", TestDataQualityApi.class); CompilerExtensionLoader.logExtensionList(); PureModel model = Compiler.compile(pureModelContextData, DeploymentMode.TEST, Identity.getAnonymousIdentity().getName()); org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement packageableElement = model.getPackageableElement("meta::dataquality::PersonDataQualityValidation"); @@ -59,8 +59,7 @@ public void testDataQualityGetPropertyPathTree() throws IOException @Test public void testDataQualityGetPropertyPathTree_WithNullDataQualityValidation() throws IOException { - URL url = Objects.requireNonNull(getClass().getClassLoader().getResource("inputs/modelWithNullDataQualityValidation.json")); - PureModelContextData pureModelContextData = objectMapper.readValue(url, PureModelContextData.class); + PureModelContextData pureModelContextData = GrammarParseTestUtils.loadPureModelContextFromResource("inputs/modelWithNullDataQualityValidation.pure", TestDataQualityApi.class); CompilerExtensionLoader.logExtensionList(); PureModel model = Compiler.compile(pureModelContextData, DeploymentMode.TEST, Identity.getAnonymousIdentity().getName()); org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement packageableElement = model.getPackageableElement("meta::dataquality::PersonDataQualityValidation"); diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/resources/inputs/modelWithDataQualityValidation.json b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/resources/inputs/modelWithDataQualityValidation.json deleted file mode 100644 index ca5cafab1d9..00000000000 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/resources/inputs/modelWithDataQualityValidation.json +++ /dev/null @@ -1,1533 +0,0 @@ -{ - "_type": "data", - "elements": [ - { - "_type": "connection", - "connectionValue": { - "_type": "RelationalDatabaseConnection", - "authenticationStrategy": { - "_type": "h2Default", - "sourceInformation": { - "endColumn": 18, - "endLine": 10, - "sourceId": "", - "startColumn": 3, - "startLine": 10 - } - }, - "databaseType": "H2", - "datasourceSpecification": { - "_type": "h2Local", - "sourceInformation": { - "endColumn": 4, - "endLine": 9, - "sourceId": "", - "startColumn": 3, - "startLine": 6 - }, - "testDataSetupSqls": [] - }, - "element": "meta::dataquality::db", - "elementSourceInformation": { - "endColumn": 30, - "endLine": 4, - "sourceId": "", - "startColumn": 10, - "startLine": 4 - }, - "postProcessorWithParameter": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 11, - "sourceId": "", - "startColumn": 1, - "startLine": 2 - }, - "type": "H2" - }, - "name": "H2", - "package": "meta::dataquality", - "sourceInformation": { - "endColumn": 1, - "endLine": 11, - "sourceId": "", - "startColumn": 1, - "startLine": 2 - } - }, - { - "_type": "relational", - "filters": [], - "includedStores": [], - "joins": [ - { - "name": "Address_Person", - "operation": { - "_type": "dynaFunc", - "funcName": "equal", - "parameters": [ - { - "_type": "column", - "column": "ID", - "sourceInformation": { - "endColumn": 62, - "endLine": 20, - "sourceId": "", - "startColumn": 24, - "startLine": 20 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 35, - "endLine": 20, - "sourceId": "", - "startColumn": 24, - "startLine": 20 - }, - "table": "addressTable" - }, - "tableAlias": "addressTable" - }, - { - "_type": "column", - "column": "ADDRESSID", - "sourceInformation": { - "endColumn": 62, - "endLine": 20, - "sourceId": "", - "startColumn": 42, - "startLine": 20 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 52, - "endLine": 20, - "sourceId": "", - "startColumn": 42, - "startLine": 20 - }, - "table": "personTable" - }, - "tableAlias": "personTable" - } - ], - "sourceInformation": { - "endColumn": 62, - "endLine": 20, - "sourceId": "", - "startColumn": 40, - "startLine": 20 - } - }, - "sourceInformation": { - "endColumn": 63, - "endLine": 20, - "sourceId": "", - "startColumn": 4, - "startLine": 20 - } - }, - { - "name": "Address_Location", - "operation": { - "_type": "dynaFunc", - "funcName": "equal", - "parameters": [ - { - "_type": "column", - "column": "LOCATIONID", - "sourceInformation": { - "endColumn": 67, - "endLine": 21, - "sourceId": "", - "startColumn": 26, - "startLine": 21 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 37, - "endLine": 21, - "sourceId": "", - "startColumn": 26, - "startLine": 21 - }, - "table": "addressTable" - }, - "tableAlias": "addressTable" - }, - { - "_type": "column", - "column": "ID", - "sourceInformation": { - "endColumn": 67, - "endLine": 21, - "sourceId": "", - "startColumn": 52, - "startLine": 21 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 64, - "endLine": 21, - "sourceId": "", - "startColumn": 52, - "startLine": 21 - }, - "table": "locationTable" - }, - "tableAlias": "locationTable" - } - ], - "sourceInformation": { - "endColumn": 67, - "endLine": 21, - "sourceId": "", - "startColumn": 50, - "startLine": 21 - } - }, - "sourceInformation": { - "endColumn": 68, - "endLine": 21, - "sourceId": "", - "startColumn": 4, - "startLine": 21 - } - } - ], - "name": "db", - "package": "meta::dataquality", - "schemas": [ - { - "name": "default", - "sourceInformation": { - "endColumn": 1, - "endLine": 22, - "sourceId": "", - "startColumn": 1, - "startLine": 14 - }, - "tables": [ - { - "columns": [ - { - "name": "ID", - "nullable": false, - "sourceInformation": { - "endColumn": 40, - "endLine": 16, - "sourceId": "", - "startColumn": 23, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "FIRSTNAME", - "nullable": true, - "sourceInformation": { - "endColumn": 64, - "endLine": 16, - "sourceId": "", - "startColumn": 43, - "startLine": 16 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - }, - { - "name": "LASTNAME", - "nullable": true, - "sourceInformation": { - "endColumn": 87, - "endLine": 16, - "sourceId": "", - "startColumn": 67, - "startLine": 16 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - }, - { - "name": "AGE", - "nullable": true, - "sourceInformation": { - "endColumn": 96, - "endLine": 16, - "sourceId": "", - "startColumn": 90, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "ADDRESSID", - "nullable": true, - "sourceInformation": { - "endColumn": 111, - "endLine": 16, - "sourceId": "", - "startColumn": 99, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "FIRMID", - "nullable": true, - "sourceInformation": { - "endColumn": 123, - "endLine": 16, - "sourceId": "", - "startColumn": 114, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - } - ], - "milestoning": [], - "name": "personTable", - "primaryKey": [ - "ID" - ], - "sourceInformation": { - "endColumn": 124, - "endLine": 16, - "sourceId": "", - "startColumn": 4, - "startLine": 16 - } - }, - { - "columns": [ - { - "name": "ID", - "nullable": false, - "sourceInformation": { - "endColumn": 41, - "endLine": 17, - "sourceId": "", - "startColumn": 24, - "startLine": 17 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "LOCATIONID", - "nullable": true, - "sourceInformation": { - "endColumn": 57, - "endLine": 17, - "sourceId": "", - "startColumn": 44, - "startLine": 17 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "TYPE", - "nullable": true, - "sourceInformation": { - "endColumn": 67, - "endLine": 17, - "sourceId": "", - "startColumn": 60, - "startLine": 17 - }, - "type": { - "_type": "Integer" - } - } - ], - "milestoning": [], - "name": "addressTable", - "primaryKey": [ - "ID" - ], - "sourceInformation": { - "endColumn": 68, - "endLine": 17, - "sourceId": "", - "startColumn": 4, - "startLine": 17 - } - }, - { - "columns": [ - { - "name": "ID", - "nullable": false, - "sourceInformation": { - "endColumn": 42, - "endLine": 18, - "sourceId": "", - "startColumn": 25, - "startLine": 18 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "STREET", - "nullable": true, - "sourceInformation": { - "endColumn": 63, - "endLine": 18, - "sourceId": "", - "startColumn": 45, - "startLine": 18 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - }, - { - "name": "LOCALITY", - "nullable": true, - "sourceInformation": { - "endColumn": 86, - "endLine": 18, - "sourceId": "", - "startColumn": 66, - "startLine": 18 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - } - ], - "milestoning": [], - "name": "locationTable", - "primaryKey": [ - "ID" - ], - "sourceInformation": { - "endColumn": 87, - "endLine": 18, - "sourceId": "", - "startColumn": 4, - "startLine": 18 - } - } - ], - "views": [] - } - ], - "sourceInformation": { - "endColumn": 1, - "endLine": 22, - "sourceId": "", - "startColumn": 1, - "startLine": 14 - }, - "stereotypes": [] - }, - { - "_type": "mapping", - "associationMappings": [], - "classMappings": [ - { - "_type": "relational", - "class": "meta::dataquality::Person", - "classSourceInformation": { - "endColumn": 28, - "endLine": 29, - "sourceId": "", - "startColumn": 4, - "startLine": 29 - }, - "distinct": false, - "groupBy": [], - "primaryKey": [], - "propertyMappings": [ - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Person", - "property": "name", - "sourceInformation": { - "endColumn": 10, - "endLine": 31, - "sourceId": "", - "startColumn": 7, - "startLine": 31 - } - }, - "relationalOperation": { - "_type": "column", - "column": "FIRSTNAME", - "sourceInformation": { - "endColumn": 57, - "endLine": 31, - "sourceId": "", - "startColumn": 14, - "startLine": 31 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 47, - "endLine": 31, - "sourceId": "", - "startColumn": 37, - "startLine": 31 - }, - "table": "personTable" - }, - "tableAlias": "personTable" - }, - "sourceInformation": { - "endColumn": 57, - "endLine": 31, - "sourceId": "", - "startColumn": 12, - "startLine": 31 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Person", - "property": "age", - "sourceInformation": { - "endColumn": 9, - "endLine": 32, - "sourceId": "", - "startColumn": 7, - "startLine": 32 - } - }, - "relationalOperation": { - "_type": "column", - "column": "AGE", - "sourceInformation": { - "endColumn": 50, - "endLine": 32, - "sourceId": "", - "startColumn": 13, - "startLine": 32 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 46, - "endLine": 32, - "sourceId": "", - "startColumn": 36, - "startLine": 32 - }, - "table": "personTable" - }, - "tableAlias": "personTable" - }, - "sourceInformation": { - "endColumn": 50, - "endLine": 32, - "sourceId": "", - "startColumn": 11, - "startLine": 32 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Person", - "property": "addresses", - "sourceInformation": { - "endColumn": 15, - "endLine": 33, - "sourceId": "", - "startColumn": 7, - "startLine": 33 - } - }, - "relationalOperation": { - "_type": "elemtWithJoins", - "joins": [ - { - "db": "meta::dataquality::db", - "name": "Address_Person", - "sourceInformation": { - "endColumn": 56, - "endLine": 33, - "sourceId": "", - "startColumn": 42, - "startLine": 33 - } - } - ], - "sourceInformation": { - "endColumn": 56, - "endLine": 33, - "sourceId": "", - "startColumn": 19, - "startLine": 33 - } - }, - "sourceInformation": { - "endColumn": 56, - "endLine": 33, - "sourceId": "", - "startColumn": 17, - "startLine": 33 - } - } - ], - "root": false, - "sourceInformation": { - "endColumn": 4, - "endLine": 34, - "sourceId": "", - "startColumn": 4, - "startLine": 29 - } - }, - { - "_type": "relational", - "class": "meta::dataquality::Address", - "classSourceInformation": { - "endColumn": 29, - "endLine": 36, - "sourceId": "", - "startColumn": 4, - "startLine": 36 - }, - "distinct": false, - "groupBy": [], - "primaryKey": [], - "propertyMappings": [ - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Address", - "property": "addressId", - "sourceInformation": { - "endColumn": 15, - "endLine": 38, - "sourceId": "", - "startColumn": 7, - "startLine": 38 - } - }, - "relationalOperation": { - "_type": "column", - "column": "ID", - "sourceInformation": { - "endColumn": 56, - "endLine": 38, - "sourceId": "", - "startColumn": 19, - "startLine": 38 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 53, - "endLine": 38, - "sourceId": "", - "startColumn": 42, - "startLine": 38 - }, - "table": "addressTable" - }, - "tableAlias": "addressTable" - }, - "sourceInformation": { - "endColumn": 56, - "endLine": 38, - "sourceId": "", - "startColumn": 17, - "startLine": 38 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Address", - "property": "location", - "sourceInformation": { - "endColumn": 14, - "endLine": 39, - "sourceId": "", - "startColumn": 7, - "startLine": 39 - } - }, - "relationalOperation": { - "_type": "elemtWithJoins", - "joins": [ - { - "db": "meta::dataquality::db", - "name": "Address_Location", - "sourceInformation": { - "endColumn": 57, - "endLine": 39, - "sourceId": "", - "startColumn": 41, - "startLine": 39 - } - } - ], - "sourceInformation": { - "endColumn": 57, - "endLine": 39, - "sourceId": "", - "startColumn": 18, - "startLine": 39 - } - }, - "sourceInformation": { - "endColumn": 57, - "endLine": 39, - "sourceId": "", - "startColumn": 16, - "startLine": 39 - } - } - ], - "root": false, - "sourceInformation": { - "endColumn": 4, - "endLine": 40, - "sourceId": "", - "startColumn": 4, - "startLine": 36 - } - }, - { - "_type": "relational", - "class": "meta::dataquality::Location", - "classSourceInformation": { - "endColumn": 30, - "endLine": 42, - "sourceId": "", - "startColumn": 4, - "startLine": 42 - }, - "distinct": false, - "groupBy": [], - "primaryKey": [], - "propertyMappings": [ - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Location", - "property": "street", - "sourceInformation": { - "endColumn": 12, - "endLine": 44, - "sourceId": "", - "startColumn": 7, - "startLine": 44 - } - }, - "relationalOperation": { - "_type": "column", - "column": "STREET", - "sourceInformation": { - "endColumn": 58, - "endLine": 44, - "sourceId": "", - "startColumn": 16, - "startLine": 44 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 51, - "endLine": 44, - "sourceId": "", - "startColumn": 39, - "startLine": 44 - }, - "table": "locationTable" - }, - "tableAlias": "locationTable" - }, - "sourceInformation": { - "endColumn": 58, - "endLine": 44, - "sourceId": "", - "startColumn": 14, - "startLine": 44 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Location", - "property": "locality", - "sourceInformation": { - "endColumn": 14, - "endLine": 45, - "sourceId": "", - "startColumn": 7, - "startLine": 45 - } - }, - "relationalOperation": { - "_type": "column", - "column": "LOCALITY", - "sourceInformation": { - "endColumn": 62, - "endLine": 45, - "sourceId": "", - "startColumn": 18, - "startLine": 45 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 53, - "endLine": 45, - "sourceId": "", - "startColumn": 41, - "startLine": 45 - }, - "table": "locationTable" - }, - "tableAlias": "locationTable" - }, - "sourceInformation": { - "endColumn": 62, - "endLine": 45, - "sourceId": "", - "startColumn": 16, - "startLine": 45 - } - } - ], - "root": false, - "sourceInformation": { - "endColumn": 4, - "endLine": 46, - "sourceId": "", - "startColumn": 4, - "startLine": 42 - } - } - ], - "enumerationMappings": [], - "includedMappings": [], - "name": "dataqualitymappings", - "package": "meta::dataquality", - "sourceInformation": { - "endColumn": 1, - "endLine": 47, - "sourceId": "", - "startColumn": 1, - "startLine": 26 - }, - "tests": [] - }, - { - "_type": "runtime", - "name": "DataQualityRuntime", - "package": "meta::dataquality", - "runtimeValue": { - "_type": "engineRuntime", - "connectionStores": [], - "connections": [ - { - "sourceInformation": { - "endColumn": 5, - "endLine": 61, - "sourceId": "", - "startColumn": 5, - "startLine": 58 - }, - "store": { - "path": "meta::dataquality::db", - "sourceInformation": { - "endColumn": 25, - "endLine": 58, - "sourceId": "", - "startColumn": 5, - "startLine": 58 - }, - "type": "STORE" - }, - "storeConnections": [ - { - "connection": { - "_type": "connectionPointer", - "connection": "meta::dataquality::H2", - "sourceInformation": { - "endColumn": 41, - "endLine": 60, - "sourceId": "", - "startColumn": 21, - "startLine": 60 - } - }, - "id": "connection_1", - "sourceInformation": { - "endColumn": 41, - "endLine": 60, - "sourceId": "", - "startColumn": 7, - "startLine": 60 - } - } - ] - } - ], - "mappings": [ - { - "path": "meta::dataquality::dataqualitymappings", - "sourceInformation": { - "endColumn": 42, - "endLine": 54, - "sourceId": "", - "startColumn": 5, - "startLine": 54 - }, - "type": "MAPPING" - } - ], - "sourceInformation": { - "endColumn": 1, - "endLine": 63, - "sourceId": "", - "startColumn": 1, - "startLine": 50 - } - }, - "sourceInformation": { - "endColumn": 1, - "endLine": 63, - "sourceId": "", - "startColumn": 1, - "startLine": 50 - } - }, - { - "_type": "class", - "constraints": [ - { - "functionDefinition": { - "_type": "lambda", - "body": [ - { - "_type": "func", - "function": "greaterThanEqual", - "parameters": [ - { - "_type": "property", - "parameters": [ - { - "_type": "var", - "name": "this", - "sourceInformation": { - "endColumn": 25, - "endLine": 70, - "sourceId": "", - "startColumn": 21, - "startLine": 70 - } - } - ], - "property": "age", - "sourceInformation": { - "endColumn": 29, - "endLine": 70, - "sourceId": "", - "startColumn": 27, - "startLine": 70 - } - }, - { - "_type": "integer", - "sourceInformation": { - "endColumn": 35, - "endLine": 70, - "sourceId": "", - "startColumn": 34, - "startLine": 70 - }, - "value": 18 - } - ], - "sourceInformation": { - "endColumn": 35, - "endLine": 70, - "sourceId": "", - "startColumn": 31, - "startLine": 70 - } - } - ], - "parameters": [] - }, - "name": "mustBeOfLegalAge", - "sourceInformation": { - "endColumn": 35, - "endLine": 70, - "sourceId": "", - "startColumn": 3, - "startLine": 70 - } - } - ], - "name": "Person", - "originalMilestonedProperties": [], - "package": "meta::dataquality", - "properties": [ - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "name", - "propertyTypeSourceInformation": { - "endColumn": 16, - "endLine": 73, - "sourceId": "", - "startColumn": 11, - "startLine": 73 - }, - "sourceInformation": { - "endColumn": 20, - "endLine": 73, - "sourceId": "", - "startColumn": 4, - "startLine": 73 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "age", - "propertyTypeSourceInformation": { - "endColumn": 16, - "endLine": 74, - "sourceId": "", - "startColumn": 10, - "startLine": 74 - }, - "sourceInformation": { - "endColumn": 20, - "endLine": 74, - "sourceId": "", - "startColumn": 4, - "startLine": 74 - }, - "stereotypes": [], - "taggedValues": [], - "type": "Integer" - }, - { - "multiplicity": { - "lowerBound": 0 - }, - "name": "addresses", - "propertyTypeSourceInformation": { - "endColumn": 41, - "endLine": 75, - "sourceId": "", - "startColumn": 16, - "startLine": 75 - }, - "sourceInformation": { - "endColumn": 45, - "endLine": 75, - "sourceId": "", - "startColumn": 4, - "startLine": 75 - }, - "stereotypes": [], - "taggedValues": [], - "type": "meta::dataquality::Address" - } - ], - "qualifiedProperties": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 76, - "sourceId": "", - "startColumn": 1, - "startLine": 68 - }, - "stereotypes": [], - "superTypes": [], - "taggedValues": [] - }, - { - "_type": "class", - "constraints": [], - "name": "Address", - "originalMilestonedProperties": [], - "package": "meta::dataquality", - "properties": [ - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "location", - "propertyTypeSourceInformation": { - "endColumn": 40, - "endLine": 80, - "sourceId": "", - "startColumn": 14, - "startLine": 80 - }, - "sourceInformation": { - "endColumn": 44, - "endLine": 80, - "sourceId": "", - "startColumn": 4, - "startLine": 80 - }, - "stereotypes": [], - "taggedValues": [], - "type": "meta::dataquality::Location" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "locationStreet", - "propertyTypeSourceInformation": { - "endColumn": 25, - "endLine": 81, - "sourceId": "", - "startColumn": 20, - "startLine": 81 - }, - "sourceInformation": { - "endColumn": 29, - "endLine": 81, - "sourceId": "", - "startColumn": 4, - "startLine": 81 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "addressId", - "propertyTypeSourceInformation": { - "endColumn": 20, - "endLine": 82, - "sourceId": "", - "startColumn": 15, - "startLine": 82 - }, - "sourceInformation": { - "endColumn": 24, - "endLine": 82, - "sourceId": "", - "startColumn": 4, - "startLine": 82 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - } - ], - "qualifiedProperties": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 83, - "sourceId": "", - "startColumn": 1, - "startLine": 78 - }, - "stereotypes": [], - "superTypes": [], - "taggedValues": [] - }, - { - "_type": "class", - "constraints": [], - "name": "Location", - "originalMilestonedProperties": [], - "package": "meta::dataquality", - "properties": [ - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "street", - "propertyTypeSourceInformation": { - "endColumn": 17, - "endLine": 87, - "sourceId": "", - "startColumn": 12, - "startLine": 87 - }, - "sourceInformation": { - "endColumn": 21, - "endLine": 87, - "sourceId": "", - "startColumn": 4, - "startLine": 87 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "locality", - "propertyTypeSourceInformation": { - "endColumn": 19, - "endLine": 88, - "sourceId": "", - "startColumn": 14, - "startLine": 88 - }, - "sourceInformation": { - "endColumn": 23, - "endLine": 88, - "sourceId": "", - "startColumn": 4, - "startLine": 88 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - } - ], - "qualifiedProperties": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 89, - "sourceId": "", - "startColumn": 1, - "startLine": 85 - }, - "stereotypes": [], - "superTypes": [], - "taggedValues": [] - }, - { - "_type": "dataQualityValidation", - "context": { - "_type": "mappingAndRuntimeDataQualityExecutionContext", - "_type": "mappingAndRuntimeDataQualityExecutionContext", - "mapping": { - "path": "meta::dataquality::dataqualitymappings", - "sourceInformation": { - "endColumn": 73, - "endLine": 94, - "sourceId": "", - "startColumn": 36, - "startLine": 94 - }, - "type": "MAPPING" - }, - "runtime": { - "path": "meta::dataquality::DataQualityRuntime", - "sourceInformation": { - "endColumn": 112, - "endLine": 94, - "sourceId": "", - "startColumn": 76, - "startLine": 94 - }, - "type": "RUNTIME" - } - }, - "dataQualityRootGraphFetchTree": { - "_type": "dataQualityRootGraphFetchTree", - "_type": "dataQualityRootGraphFetchTree", - "class": "meta::dataquality::Person", - "constraints": [ - "mustBeOfLegalAge" - ], - "sourceInformation": { - "endColumn": 31, - "endLine": 97, - "sourceId": "", - "startColumn": 7, - "startLine": 97 - }, - "subTrees": [ - { - "_type": "dataQualityPropertyGraphFetchTree", - "_type": "dataQualityPropertyGraphFetchTree", - "constraints": [], - "parameters": [], - "property": "name", - "sourceInformation": { - "endColumn": 12, - "endLine": 98, - "sourceId": "", - "startColumn": 9, - "startLine": 98 - }, - "subTrees": [], - "subTypeTrees": [] - } - ], - "subTypeTrees": [] - }, - "filter": { - "_type": "lambda", - "body": [ - { - "_type": "func", - "function": "equal", - "parameters": [ - { - "_type": "property", - "parameters": [ - { - "_type": "var", - "name": "p", - "sourceInformation": { - "endColumn": 47, - "endLine": 95, - "sourceId": "", - "startColumn": 46, - "startLine": 95 - } - } - ], - "property": "name", - "sourceInformation": { - "endColumn": 52, - "endLine": 95, - "sourceId": "", - "startColumn": 49, - "startLine": 95 - } - }, - { - "_type": "string", - "sourceInformation": { - "endColumn": 60, - "endLine": 95, - "sourceId": "", - "startColumn": 55, - "startLine": 95 - }, - "value": "John" - } - ], - "sourceInformation": { - "endColumn": 54, - "endLine": 95, - "sourceId": "", - "startColumn": 53, - "startLine": 95 - } - } - ], - "parameters": [ - { - "_type": "var", - "class": "meta::dataquality::Person", - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "p", - "sourceInformation": { - "endColumn": 39, - "endLine": 95, - "sourceId": "", - "startColumn": 15, - "startLine": 95 - } - } - ], - "sourceInformation": { - "endColumn": 60, - "endLine": 95, - "sourceId": "", - "startColumn": 44, - "startLine": 95 - } - }, - "name": "PersonDataQualityValidation", - "package": "meta::dataquality", - "sourceInformation": { - "endColumn": 1, - "endLine": 101, - "sourceId": "", - "startColumn": 1, - "startLine": 92 - }, - "stereotypes": [], - "taggedValues": [] - }, - { - "_type": "sectionIndex", - "name": "SectionIndex", - "package": "__internal__", - "sections": [ - { - "_type": "importAware", - "elements": [], - "imports": [], - "parserName": "Pure", - "sourceInformation": { - "endColumn": 8, - "endLine": 1, - "sourceId": "", - "startColumn": 1, - "startLine": 1 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::H2" - ], - "imports": [], - "parserName": "Connection", - "sourceInformation": { - "endColumn": 2, - "endLine": 13, - "sourceId": "", - "startColumn": 8, - "startLine": 2 - } - }, - { - "_type": "default", - "elements": [ - "meta::dataquality::db" - ], - "parserName": "Relational", - "sourceInformation": { - "endColumn": 1, - "endLine": 25, - "sourceId": "", - "startColumn": 1, - "startLine": 14 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::dataqualitymappings" - ], - "imports": [], - "parserName": "Mapping", - "sourceInformation": { - "endColumn": 2, - "endLine": 49, - "sourceId": "", - "startColumn": 1, - "startLine": 26 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::DataQualityRuntime" - ], - "imports": [], - "parserName": "Runtime", - "sourceInformation": { - "endColumn": 1, - "endLine": 67, - "sourceId": "", - "startColumn": 1, - "startLine": 50 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::Person", - "meta::dataquality::Address", - "meta::dataquality::Location" - ], - "imports": [], - "parserName": "Pure", - "sourceInformation": { - "endColumn": 2, - "endLine": 91, - "sourceId": "", - "startColumn": 1, - "startLine": 68 - } - }, - { - "_type": "default", - "elements": [ - "meta::dataquality::PersonDataQualityValidation" - ], - "parserName": "DataQualityValidation", - "sourceInformation": { - "endColumn": 1, - "endLine": 103, - "sourceId": "", - "startColumn": 1, - "startLine": 92 - } - } - ] - } - ] -} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/resources/inputs/modelWithDataQualityValidation.pure b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/resources/inputs/modelWithDataQualityValidation.pure new file mode 100644 index 00000000000..4881285c8ce --- /dev/null +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-api/src/test/resources/inputs/modelWithDataQualityValidation.pure @@ -0,0 +1,117 @@ +###Connection +RelationalDatabaseConnection meta::dataquality::H2 +{ + store: meta::dataquality::db; + type: H2; + specification: LocalH2 + { + }; + auth: DefaultH2; +} + + +###Relational +Database meta::dataquality::db +( + Table personTable + ( + ID INTEGER PRIMARY KEY, + FIRSTNAME VARCHAR(200), + LASTNAME VARCHAR(200), + AGE INTEGER, + ADDRESSID INTEGER, + FIRMID INTEGER + ) + Table addressTable + ( + ID INTEGER PRIMARY KEY, + LOCATIONID INTEGER, + TYPE INTEGER + ) + Table locationTable + ( + ID INTEGER PRIMARY KEY, + STREET VARCHAR(200), + LOCALITY VARCHAR(200) + ) + + Join Address_Person(addressTable.ID = personTable.ADDRESSID) + Join Address_Location(addressTable.LOCATIONID = locationTable.ID) +) + + +###Mapping +Mapping meta::dataquality::dataqualitymappings +( + meta::dataquality::Person: Relational + { + name: [meta::dataquality::db]personTable.FIRSTNAME, + age: [meta::dataquality::db]personTable.AGE, + addresses: [meta::dataquality::db]@Address_Person + } + meta::dataquality::Address: Relational + { + addressId: [meta::dataquality::db]addressTable.ID, + location: [meta::dataquality::db]@Address_Location + } + meta::dataquality::Location: Relational + { + street: [meta::dataquality::db]locationTable.STREET, + locality: [meta::dataquality::db]locationTable.LOCALITY + } +) + + +###Runtime +Runtime meta::dataquality::DataQualityRuntime +{ + mappings: + [ + meta::dataquality::dataqualitymappings + ]; + connections: + [ + meta::dataquality::db: + [ + connection_1: meta::dataquality::H2 + ] + ]; +} + + +###Pure +Class meta::dataquality::Person +[ + mustBeOfLegalAge: $this.age >= 18 +] +{ + name: String[1]; + age: Integer[1]; + addresses: meta::dataquality::Address[*]; +} + +Class meta::dataquality::Address +{ + location: meta::dataquality::Location[1]; + locationStreet: String[1]; + addressId: String[1]; +} + +Class meta::dataquality::Location +{ + street: String[1]; + locality: String[1]; +} + + +###DataQualityValidation +DataQualityValidation meta::dataquality::PersonDataQualityValidation +{ + context: fromMappingAndRuntime(meta::dataquality::dataqualitymappings, meta::dataquality::DataQualityRuntime); + validationTree: $[ + meta::dataquality::Person{ + name + } + ]$; + filter: p: meta::dataquality::Person[1]|$p.name == 'John'; +} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/pom.xml b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/pom.xml index 665930a878f..4c92ef2b0e2 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/pom.xml +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-dataquality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataQualityCompilerExtension.java b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataQualityCompilerExtension.java index 1d0ee0d930e..92aba1ae064 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataQualityCompilerExtension.java +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DataQualityCompilerExtension.java @@ -79,6 +79,16 @@ public CompilerExtension build() return new DataQualityCompilerExtension(); } + + private GenericType genericType(CompileContext context, String _class) + { + GenericType gt = context.resolveGenericType("meta::external::dataquality::DataQuality"); + + return gt._typeArguments(org.eclipse.collections.impl.factory.Lists.fixedSize.of( + context.resolveGenericType(_class) + )); + } + @Override public Iterable> getExtraProcessors() { @@ -88,24 +98,16 @@ public Iterable> getExtraProcessors() org.eclipse.collections.impl.factory.Lists.fixedSize.with(PackageableRuntime.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping.class, org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class.class, DataSpace.class), (dataquality, compileContext) -> { - Root_meta_external_dataquality_DataQuality_Impl metamodel = new Root_meta_external_dataquality_DataQuality_Impl<>( + Root_meta_external_dataquality_DataQuality metamodel = new Root_meta_external_dataquality_DataQuality_Impl<>( dataquality.name, SourceInformationHelper.toM3SourceInformation(dataquality.sourceInformation), compileContext.pureModel.getClass("meta::external::dataquality::DataQuality") - ); + )._classifierGenericType(genericType(compileContext, dataquality.dataQualityRootGraphFetchTree._class)); return metamodel; }, (dataquality, compileContext) -> { - }, - (dataquality, compileContext) -> - { - - }, - (dataquality, compileContext) -> - { - }, (dataquality, compileContext) -> { @@ -221,6 +223,7 @@ private static Root_meta_external_dataquality_DataQualityRootGraphFetchTree buil GenericType genericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("", null, context.pureModel.getClass("meta::pure::metamodel::type::generics::GenericType")) ._rawType(classifier) ._typeArguments(org.eclipse.collections.impl.factory.Lists.fixedSize.of(context.pureModel.getGenericType(parentClass))); + return new Root_meta_external_dataquality_DataQualityRootGraphFetchTree_Impl<>("", SourceInformationHelper.toM3SourceInformation(rootGraphFetchTree.sourceInformation), classifier) ._class(parentClass) ._classifierGenericType(genericType) diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/pom.xml b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/pom.xml index d194f40267c..5e661355dad 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/pom.xml +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-dataquality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -62,10 +62,6 @@ - - org.finos.legend.engine - legend-engine-language-pure-grammar - org.finos.legend.engine legend-engine-pure-code-core-extension @@ -162,6 +158,22 @@ json-unit test + + org.finos.legend.engine + legend-engine-xt-dataquality-pure-test + test + + + org.finos.legend.engine + legend-engine-language-pure-grammar + test + test-jar + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler + runtime + diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityLambdaGenerator.java b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityLambdaGenerator.java index 1f7d45850ca..e96fb0815de 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityLambdaGenerator.java +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityLambdaGenerator.java @@ -39,18 +39,18 @@ public class DataQualityLambdaGenerator { public static final int DEFAULT_QUERY_LIMIT = 100; - public static LambdaFunction generateLambda(PureModel pureModel, String qualifiedPath) + public static LambdaFunction generateLambda(PureModel pureModel, String qualifiedPath, Function> extensions) { PackageableElement packageableElement = pureModel.getPackageableElement(qualifiedPath); - return generateLambda(pureModel, packageableElement); + return generateLambda(pureModel, packageableElement, extensions); } - public static LambdaFunction generateLambda(PureModel pureModel, PackageableElement packageableElement) + public static LambdaFunction generateLambda(PureModel pureModel, PackageableElement packageableElement, Function> extensions) { - return core_dataquality_generation_dataquality.Root_meta_external_dataquality_executeDataQualityValidation_DataQuality_1__Integer_MANY__LambdaFunction_1_((Root_meta_external_dataquality_DataQuality)packageableElement, Lists.immutable.empty(), pureModel.getExecutionSupport()); + return core_dataquality_generation_dataquality.Root_meta_external_dataquality_generateDataQualityQuery_DataQuality_1__Integer_MANY__LambdaFunction_1_((Root_meta_external_dataquality_DataQuality) packageableElement, Lists.immutable.empty(), pureModel.getExecutionSupport()); } - public static LambdaFunction generateLambdaForTrial(PureModel pureModel, String qualifiedPath, Integer queryLimit) + public static LambdaFunction generateLambdaForTrial(PureModel pureModel, String qualifiedPath, Integer queryLimit, Function> extensions) { PackageableElement packageableElement = pureModel.getPackageableElement(qualifiedPath); int trialQueryLimit = DEFAULT_QUERY_LIMIT; @@ -58,7 +58,8 @@ public static LambdaFunction generateLambdaForTrial(PureModel pureModel, String { trialQueryLimit = queryLimit; } - return core_dataquality_generation_dataquality.Root_meta_external_dataquality_executeDataQualityValidation_DataQuality_1__Integer_MANY__LambdaFunction_1_((Root_meta_external_dataquality_DataQuality)packageableElement, Lists.immutable.of((long)trialQueryLimit), pureModel.getExecutionSupport()); + + return core_dataquality_generation_dataquality.Root_meta_external_dataquality_generateDataQualityQuery_DataQuality_1__Integer_MANY__LambdaFunction_1_((Root_meta_external_dataquality_DataQuality)packageableElement, Lists.immutable.of((long)trialQueryLimit), pureModel.getExecutionSupport()); } public static Lambda transformLambda(LambdaFunction lambda, PureModel pureModel, Function> extensions) diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityValidationArtifactGenerationExtension.java b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityValidationArtifactGenerationExtension.java index 6b640b385cf..6d9e87aa439 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityValidationArtifactGenerationExtension.java +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/main/java/org/finos/legend/engine/generation/dataquality/DataQualityValidationArtifactGenerationExtension.java @@ -80,7 +80,7 @@ public List generate(PackageableElement packageableElement, PureModel Function> routerExtensions = (PureModel p) -> PureCoreExtensionLoader.extensions().flatCollect(e -> e.extraPureCoreExtensions(p.getExecutionSupport())); // 1. call DQ PURE func to generate lambda - LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambda(pureModel, packageableElement); + LambdaFunction dqLambdaFunction = DataQualityLambdaGenerator.generateLambda(pureModel, packageableElement, routerExtensions); // 2. Generate Plan from the lambda generated in the previous step SingleExecutionPlan singleExecutionPlan = PlanGenerator.generateExecutionPlan(dqLambdaFunction, null, null, null, pureModel, clientVersion, PlanPlatform.JAVA, null, routerExtensions.apply(pureModel), LegendPlanTransformers.transformers);// since lambda has from function we dont need mapping, runtime and context diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityLambdaGenerator.java b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityLambdaGenerator.java index b7305e84c1a..3973d45560c 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityLambdaGenerator.java +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityLambdaGenerator.java @@ -18,9 +18,10 @@ import net.javacrumbs.jsonunit.core.Option; import org.eclipse.collections.api.RichIterable; import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.impl.list.mutable.FastList; import org.finos.legend.engine.language.pure.compiler.Compiler; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; -import org.finos.legend.engine.language.pure.grammar.from.PureGrammarParser; +import org.finos.legend.engine.language.pure.grammar.test.GrammarParseTestUtils; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.pure.code.core.PureCoreExtensionLoader; import org.finos.legend.engine.shared.core.deployment.DeploymentMode; @@ -33,19 +34,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; +//NOTE: conversion tests can be found in the pure-test module. Tests here are to ensure the java->pure flow e2e. public class TestDataQualityLambdaGenerator { @Test - public void testAssertionForNestedConstraints() + public void testNestedConstraints() { - String validation = COMPILATION_PREREQUISITE_CODE + - "###DataQualityValidation\n" + - "DataQualityValidation meta::dataquality::PersonDataQualityValidation\n" + + String validation = "###DataQualityValidation\n" + + "DataQualityValidation meta::dataquality::Validation\n" + "{\n" + - " context: fromMappingAndRuntime(meta::dataquality::dataqualitymappings, meta::dataquality::DataQualityRuntime);\n" + - " filter: p:meta::dataquality::Person[1] | $p.name=='John';\n" + + " context: fromMappingAndRuntime(meta::external::dataquality::tests::domain::dataqualitymappings, meta::external::dataquality::tests::domain::DataQualityRuntime);\n" + " validationTree: $[\n" + - " meta::dataquality::Person{\n" + + " meta::external::dataquality::tests::domain::Person{\n" + " name,\n" + " addresses{\n" + " addressId\n" + @@ -53,132 +53,60 @@ public void testAssertionForNestedConstraints() " }\n" + " ]$;\n" + "}"; - PureModelContextData modelData = PureGrammarParser.newInstance().parseModel(validation); - PureModel model = Compiler.compile(modelData, DeploymentMode.TEST_IGNORE_FUNCTION_MATCH, Identity.getAnonymousIdentity().getName()); - assertEquals("Nested constraints are not currently supported!", - assertThrows(PureAssertFailException.class, () -> DataQualityLambdaGenerator.generateLambda(model, "meta::dataquality::PersonDataQualityValidation")).getInfo()); + assertLambdaException(validation, "Nested constraints are not currently supported!"); } @Test - public void testLambdaGeneration_multipleConstraints() + public void testLambdaGeneration() { - String validation = COMPILATION_PREREQUISITE_CODE + - "###DataQualityValidation\n" + - "DataQualityValidation meta::dataquality::PersonDataQualityValidation\n" + + String validation = "###DataQualityValidation\n" + + "DataQualityValidation meta::dataquality::Validation\n" + "{\n" + - " context: fromMappingAndRuntime(meta::dataquality::dataqualitymappings, meta::dataquality::DataQualityRuntime);\n" + + " context: fromMappingAndRuntime(meta::external::dataquality::tests::domain::dataqualitymappings, meta::external::dataquality::tests::domain::DataQualityRuntime);\n" + " validationTree: $[\n" + - " meta::dataquality::Person{\n" + - " name,\n" + - " addresses{\n" + - " addressId\n" + - " }\n" + + " meta::external::dataquality::tests::domain::Person{\n" + + " name" + " }\n" + " ]$;\n" + "}"; - PureModelContextData modelData = PureGrammarParser.newInstance().parseModel(validation); + + String expected = "{\"_type\":\"lambda\",\"body\":[{\"fControl\":\"from_T_m__Mapping_1__Runtime_1__T_m_\",\"function\":\"from\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"serialize_Checked_MANY__RootGraphFetchTree_1__String_1_\",\"function\":\"serialize\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"graphFetchChecked_T_MANY__RootGraphFetchTree_1__Checked_MANY_\",\"function\":\"graphFetchChecked\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"filter_T_MANY__Function_1__T_MANY_\",\"function\":\"filter\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"getAll_Class_1__T_MANY_\",\"function\":\"getAll\",\"_type\":\"func\",\"parameters\":[{\"fullPath\":\"meta::external::dataquality::tests::domain::Person\",\"_type\":\"packageableElementPtr\"}]},{\"_type\":\"lambda\",\"body\":[{\"fControl\":\"not_Boolean_1__Boolean_1_\",\"function\":\"not\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"greaterThanEqual_Number_1__Number_1__Boolean_1_\",\"function\":\"greaterThanEqual\",\"_type\":\"func\",\"parameters\":[{\"_type\":\"property\",\"property\":\"age\",\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}]},{\"_type\":\"integer\",\"value\":18}]}]}],\"parameters\":[{\"multiplicity\":{\"upperBound\":1,\"lowerBound\":1},\"_type\":\"var\",\"name\":\"x\",\"class\":\"meta::external::dataquality::tests::domain::Person\"}]}]},{\"_type\":\"classInstance\",\"type\":\"rootGraphFetchTree\",\"value\":{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"name\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"age\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::external::dataquality::tests::domain::Person\"}}]},{\"_type\":\"classInstance\",\"type\":\"rootGraphFetchTree\",\"value\":{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"name\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"age\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::external::dataquality::tests::domain::Person\"}}]},{\"fullPath\":\"meta::external::dataquality::tests::domain::dataqualitymappings\",\"_type\":\"packageableElementPtr\"},{\"_type\":\"classInstance\",\"type\":\"runtimeInstance\",\"value\":{\"runtime\":{\"_type\":\"legacyRuntime\",\"connections\":[{\"_type\":\"RelationalDatabaseConnection\",\"authenticationStrategy\":{\"_type\":\"h2Default\"},\"type\":\"H2\",\"datasourceSpecification\":{\"_type\":\"h2Local\"},\"element\":\"meta::external::dataquality::tests::domain::db\"}]}}}]}]}"; + + assertLambda(validation, expected); + } + + private void assertLambda(String modelString, String expected) + { + String lambdaJson = generateLambda(modelString); + JsonAssert.assertJsonEquals(expected, lambdaJson, JsonAssert.when(Option.IGNORING_ARRAY_ORDER)); + } + + private void assertLambdaException(String modelString, String exception) + { + assertEquals(exception, assertThrows(PureAssertFailException.class, () -> generateLambda(modelString)).getInfo()); + } + + private String generateLambda(String modelString) + { + PureModelContextData modelData = loadWithModel(modelString); PureModel model = Compiler.compile(modelData, DeploymentMode.TEST_IGNORE_FUNCTION_MATCH, Identity.getAnonymousIdentity().getName()); - LambdaFunction lambdaFunction = DataQualityLambdaGenerator.generateLambda(model, "meta::dataquality::PersonDataQualityValidation"); - Function> routerExtensions = (PureModel p) -> PureCoreExtensionLoader.extensions().flatCollect(e -> e.extraPureCoreExtensions(p.getExecutionSupport())); - String lambdaJson = DataQualityLambdaGenerator.transformLambdaAsJson(lambdaFunction, model, routerExtensions); - JsonAssert.assertJsonEquals("{\"_type\":\"lambda\",\"body\":[{\"fControl\":\"from_T_m__Mapping_1__Runtime_1__T_m_\",\"function\":\"from\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"serialize_T_MANY__RootGraphFetchTree_1__String_1_\",\"function\":\"serialize\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"graphFetchChecked_T_MANY__RootGraphFetchTree_1__Checked_MANY_\",\"function\":\"graphFetchChecked\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"filter_T_MANY__Function_1__T_MANY_\",\"function\":\"filter\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"getAll_Class_1__Date_1__T_MANY_\",\"function\":\"getAll\",\"_type\":\"func\",\"parameters\":[{\"fullPath\":\"meta::dataquality::Person\",\"_type\":\"packageableElementPtr\"},{\"_type\":\"var\",\"name\":\"businessDate\"}]},{\"_type\":\"lambda\",\"body\":[{\"fControl\":\"or_Boolean_1__Boolean_1__Boolean_1_\",\"function\":\"or\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"not_Boolean_1__Boolean_1_\",\"function\":\"not\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"greaterThanEqual_Number_1__Number_1__Boolean_1_\",\"function\":\"greaterThanEqual\",\"_type\":\"func\",\"parameters\":[{\"_type\":\"property\",\"property\":\"age\",\"parameters\":[{\"_type\":\"var\",\"name\":\"this\"}]},{\"_type\":\"integer\",\"value\":0}]}]},{\"fControl\":\"or_Boolean_1__Boolean_1__Boolean_1_\",\"function\":\"or\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"not_Boolean_1__Boolean_1_\",\"function\":\"not\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"greaterThanEqual_Number_1__Number_1__Boolean_1_\",\"function\":\"greaterThanEqual\",\"_type\":\"func\",\"parameters\":[{\"_type\":\"property\",\"property\":\"age\",\"parameters\":[{\"_type\":\"var\",\"name\":\"this\"}]},{\"_type\":\"integer\",\"value\":18}]}]},{\"fControl\":\"not_Boolean_1__Boolean_1_\",\"function\":\"not\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"lessThan_Number_1__Number_1__Boolean_1_\",\"function\":\"lessThan\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"length_String_1__Integer_1_\",\"function\":\"length\",\"_type\":\"func\",\"parameters\":[{\"_type\":\"property\",\"property\":\"name\",\"parameters\":[{\"_type\":\"var\",\"name\":\"this\"}]}]},{\"_type\":\"integer\",\"value\":1000}]}]}]}]}]}]},{\"_type\":\"classInstance\",\"type\":\"rootGraphFetchTree\",\"value\":{\"subTrees\":[{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"addressId\"}],\"_type\":\"propertyGraphFetchTree\",\"property\":\"addresses\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"age\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"name\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::dataquality::Person\"}}]},{\"_type\":\"classInstance\",\"type\":\"rootGraphFetchTree\",\"value\":{\"subTrees\":[{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"addressId\"}],\"_type\":\"propertyGraphFetchTree\",\"property\":\"addresses\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"age\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"name\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::dataquality::Person\"}}]},{\"fullPath\":\"meta::dataquality::dataqualitymappings\",\"_type\":\"packageableElementPtr\"},{\"_type\":\"classInstance\",\"type\":\"runtimeInstance\",\"value\":{\"runtime\":{\"_type\":\"legacyRuntime\",\"connections\":[{\"_type\":\"RelationalDatabaseConnection\",\"authenticationStrategy\":{\"_type\":\"h2Default\"},\"type\":\"H2\",\"datasourceSpecification\":{\"_type\":\"h2Local\"},\"element\":\"meta::dataquality::db\"}]}}}]}]}", - lambdaJson, JsonAssert.when(Option.IGNORING_ARRAY_ORDER)); + Function> routerExtensions = extensions(); + LambdaFunction lambdaFunction = DataQualityLambdaGenerator.generateLambda(model, "meta::dataquality::Validation", routerExtensions); + return DataQualityLambdaGenerator.transformLambdaAsJson(lambdaFunction, model, routerExtensions); } - private static final String COMPILATION_PREREQUISITE_CODE = "###Connection\n" + - "RelationalDatabaseConnection meta::dataquality::H2\n" + - "{\n" + - " store: meta::dataquality::db;\n" + - " type: H2;\n" + - " specification: LocalH2\n" + - " { \n" + - " testDataSetupSqls: [];\n" + - " };\n" + - " auth: DefaultH2;\n" + - "}\n" + - "\n" + - "###Relational\n" + - "Database meta::dataquality::db\n" + - "(\n" + - " Table personTable (ID INT PRIMARY KEY, FIRSTNAME VARCHAR(200), LASTNAME VARCHAR(200), AGE INT, ADDRESSID INT, FIRMID INT)\n" + - " Table addressTable (ID INT PRIMARY KEY, LOCATIONID INT, TYPE INT)\n" + - " Table locationTable (ID INT PRIMARY KEY, STREET VARCHAR(200), LOCALITY VARCHAR(200))\n" + - "\n" + - " Join Address_Person(addressTable.ID = personTable.ADDRESSID)\n" + - " Join Address_Location(addressTable.LOCATIONID = locationTable.ID)\n" + - ")\n" + - "\n" + - "\n" + - "###Mapping\n" + - "Mapping meta::dataquality::dataqualitymappings\n" + - "(\n" + - "\n" + - " meta::dataquality::Person : Relational\n" + - " {\n" + - " name : [meta::dataquality::db]personTable.FIRSTNAME,\n" + - " age : [meta::dataquality::db]personTable.AGE,\n" + - " addresses : [meta::dataquality::db]@Address_Person\n" + - " }\n" + - "\n" + - " meta::dataquality::Address : Relational\n" + - " {\n" + - " addressId : [meta::dataquality::db]addressTable.ID,\n" + - " location : [meta::dataquality::db]@Address_Location\n" + - " }\n" + - "\n" + - " meta::dataquality::Location : Relational\n" + - " {\n" + - " street : [meta::dataquality::db]locationTable.STREET,\n" + - " locality : [meta::dataquality::db]locationTable.LOCALITY\n" + - " }\n" + - ")\n" + - "\n" + - "###Runtime\n" + - "Runtime meta::dataquality::DataQualityRuntime\n" + - "{\n" + - " mappings:\n" + - " [\n" + - " meta::dataquality::dataqualitymappings\n" + - " ];\n" + - " connections:\n" + - " [\n" + - " meta::dataquality::db:\n" + - " [\n" + - " connection_1: meta::dataquality::H2\n" + - " ]\n" + - " ];\n" + - "}\n" + - "\n" + - "\n" + - "\n" + - "###Pure\n" + - "Class meta::dataquality::Person\n" + - "[\n" + - " mustBeOfLegalAge: $this.age >= 18,\n" + - " validNameLength: $this.name->length() < 1000,\n" + - " ageMustBePositive: $this.age >= 0\n" + - "]\n" + - "{\n" + - " name : String[1];\n" + - " age : Integer[1];\n" + - " addresses : meta::dataquality::Address[*];\n" + - "}\n" + - "\n" + - "Class meta::dataquality::Address\n" + - "[\n" + - " validAddressId: $this.addressId->isNotEmpty()\n" + - "]\n" + - "{\n" + - " location: meta::dataquality::Location[1];\n" + - " locationStreet: String[1];\n" + - " addressId: String[1];\n" + - "}\n" + - "\n" + - "Class meta::dataquality::Location\n" + - "{\n" + - " street: String[1];\n" + - " locality: String[1];\n" + - "}\n"; + private static PureModelContextData loadWithModel(String code) + { + return GrammarParseTestUtils.loadPureModelContextFromResources( + FastList.newListWith( + "core_dataquality_test/dataquality_test_model.pure", + "core_dataquality_test/dataquality_test_model_legend.txt"), + code, TestDataQualityLambdaGenerator.class); + } -} + private static Function> extensions() + { + return (p) -> PureCoreExtensionLoader.extensions().flatCollect(e -> e.extraPureCoreExtensions(p.getExecutionSupport())); + } +} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityValidationArtifactGenerationExtension.java b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityValidationArtifactGenerationExtension.java index 740a5604c59..3d3ad38c285 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityValidationArtifactGenerationExtension.java +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/java/org/finos/legend/engine/generation/dataquality/TestDataQualityValidationArtifactGenerationExtension.java @@ -14,20 +14,17 @@ package org.finos.legend.engine.generation.dataquality; +import org.eclipse.collections.impl.list.mutable.FastList; import org.finos.legend.engine.language.pure.compiler.Compiler; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; -import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtensionLoader; import org.finos.legend.engine.language.pure.dsl.generation.extension.Artifact; +import org.finos.legend.engine.language.pure.grammar.test.GrammarParseTestUtils; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; -import org.finos.legend.engine.shared.core.ObjectMapperFactory; import org.finos.legend.engine.shared.core.deployment.DeploymentMode; import org.finos.legend.engine.shared.core.identity.Identity; import org.junit.Test; -import java.io.IOException; -import java.net.URL; import java.util.List; -import java.util.Objects; import java.util.Optional; import static org.junit.Assert.assertEquals; @@ -37,24 +34,39 @@ public class TestDataQualityValidationArtifactGenerationExtension { @Test - public void testDataQualityValidationArtifact() throws IOException + public void testDataQualityValidationArtifact() { - URL url = Objects.requireNonNull(getClass().getClassLoader().getResource("inputs/modelWithDataQualityValidation.json")); - PureModelContextData pureModelContextData = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports().readValue(url, PureModelContextData.class); - CompilerExtensionLoader.logExtensionList(); + String tree = "###DataQualityValidation\n" + + "DataQualityValidation meta::dataquality::Validation\n" + + "{\n" + + " context: fromMappingAndRuntime(meta::external::dataquality::tests::domain::dataqualitymappings, meta::external::dataquality::tests::domain::DataQualityRuntime);\n" + + " validationTree: $[\n" + + " meta::external::dataquality::tests::domain::Person{\n" + + " name\n" + + " }\n" + + " ]$;\n" + + " filter: p: meta::external::dataquality::tests::domain::Person[1]|$p.name == 'John';\n" + + "}"; + + PureModelContextData pureModelContextData = GrammarParseTestUtils.loadPureModelContextFromResources( + FastList.newListWith( + "core_dataquality_test/dataquality_test_model.pure", + "core_dataquality_test/dataquality_test_model_legend.txt"), + tree, TestDataQualityValidationArtifactGenerationExtension.class); PureModel model = Compiler.compile(pureModelContextData, DeploymentMode.TEST_IGNORE_FUNCTION_MATCH, Identity.getAnonymousIdentity().getName()); DataQualityValidationArtifactGenerationExtension extension = new DataQualityValidationArtifactGenerationExtension(); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement packageableElement = model.getPackageableElement("meta::dataquality::PersonDataQualityValidation"); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement packageableElement = model.getPackageableElement("meta::dataquality::Validation"); assertTrue(extension.canGenerate(packageableElement)); List outputs = extension.generate(packageableElement, model, pureModelContextData, "vX_X_X"); assertEquals(2, outputs.size()); + Optional artifactOptional = outputs.stream().filter(artifact -> "dataQualityRulesMetadata.json".equalsIgnoreCase(artifact.path)).findAny(); assertTrue(artifactOptional.isPresent()); Artifact dataQualityMetaData = artifactOptional.get(); - assertEquals("{\"dqRules\":[{\"constraintGrammar\":\"($this.age >= 18)\",\"constraintName\":\"mustBeOfLegalAge\",\"constraintType\":\"Alloy_Constraint_Validation\",\"propertyPath\":\"Person\"},{\"constraintGrammar\":\"Class\",\"constraintName\":\"Person\",\"constraintType\":\"Alloy_Class_Validation\",\"propertyPath\":\"Person\"},{\"constraintGrammar\":\"1\",\"constraintName\":\"name\",\"constraintType\":\"Alloy_Structural_Validation\",\"propertyPath\":\"Person::name\"},{\"constraintGrammar\":\"1\",\"constraintName\":\"age\",\"constraintType\":\"Alloy_Structural_Validation\",\"propertyPath\":\"Person::age\"}]}", dataQualityMetaData.content); + assertEquals("{\"dqRules\":[{\"constraintGrammar\":\"($x.age >= 18)\",\"constraintName\":\"mustBeOfLegalAge\",\"constraintType\":\"Alloy_Constraint_Validation\",\"propertyPath\":\"Person\"},{\"constraintGrammar\":\"Class\",\"constraintName\":\"Person\",\"constraintType\":\"Alloy_Class_Validation\",\"propertyPath\":\"Person\"},{\"constraintGrammar\":\"1\",\"constraintName\":\"name\",\"constraintType\":\"Alloy_Structural_Validation\",\"propertyPath\":\"Person::name\"},{\"constraintGrammar\":\"1\",\"constraintName\":\"age\",\"constraintType\":\"Alloy_Structural_Validation\",\"propertyPath\":\"Person::age\"}]}", dataQualityMetaData.content); - org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement packageableElement2 = model.getPackageableElement("meta::dataquality::Person"); + org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement packageableElement2 = model.getPackageableElement("meta::external::dataquality::tests::domain::Person"); assertFalse(extension.canGenerate(packageableElement2)); } diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/resources/inputs/modelWithDataQualityValidation.json b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/resources/inputs/modelWithDataQualityValidation.json deleted file mode 100644 index ca5cafab1d9..00000000000 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-generation/src/test/resources/inputs/modelWithDataQualityValidation.json +++ /dev/null @@ -1,1533 +0,0 @@ -{ - "_type": "data", - "elements": [ - { - "_type": "connection", - "connectionValue": { - "_type": "RelationalDatabaseConnection", - "authenticationStrategy": { - "_type": "h2Default", - "sourceInformation": { - "endColumn": 18, - "endLine": 10, - "sourceId": "", - "startColumn": 3, - "startLine": 10 - } - }, - "databaseType": "H2", - "datasourceSpecification": { - "_type": "h2Local", - "sourceInformation": { - "endColumn": 4, - "endLine": 9, - "sourceId": "", - "startColumn": 3, - "startLine": 6 - }, - "testDataSetupSqls": [] - }, - "element": "meta::dataquality::db", - "elementSourceInformation": { - "endColumn": 30, - "endLine": 4, - "sourceId": "", - "startColumn": 10, - "startLine": 4 - }, - "postProcessorWithParameter": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 11, - "sourceId": "", - "startColumn": 1, - "startLine": 2 - }, - "type": "H2" - }, - "name": "H2", - "package": "meta::dataquality", - "sourceInformation": { - "endColumn": 1, - "endLine": 11, - "sourceId": "", - "startColumn": 1, - "startLine": 2 - } - }, - { - "_type": "relational", - "filters": [], - "includedStores": [], - "joins": [ - { - "name": "Address_Person", - "operation": { - "_type": "dynaFunc", - "funcName": "equal", - "parameters": [ - { - "_type": "column", - "column": "ID", - "sourceInformation": { - "endColumn": 62, - "endLine": 20, - "sourceId": "", - "startColumn": 24, - "startLine": 20 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 35, - "endLine": 20, - "sourceId": "", - "startColumn": 24, - "startLine": 20 - }, - "table": "addressTable" - }, - "tableAlias": "addressTable" - }, - { - "_type": "column", - "column": "ADDRESSID", - "sourceInformation": { - "endColumn": 62, - "endLine": 20, - "sourceId": "", - "startColumn": 42, - "startLine": 20 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 52, - "endLine": 20, - "sourceId": "", - "startColumn": 42, - "startLine": 20 - }, - "table": "personTable" - }, - "tableAlias": "personTable" - } - ], - "sourceInformation": { - "endColumn": 62, - "endLine": 20, - "sourceId": "", - "startColumn": 40, - "startLine": 20 - } - }, - "sourceInformation": { - "endColumn": 63, - "endLine": 20, - "sourceId": "", - "startColumn": 4, - "startLine": 20 - } - }, - { - "name": "Address_Location", - "operation": { - "_type": "dynaFunc", - "funcName": "equal", - "parameters": [ - { - "_type": "column", - "column": "LOCATIONID", - "sourceInformation": { - "endColumn": 67, - "endLine": 21, - "sourceId": "", - "startColumn": 26, - "startLine": 21 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 37, - "endLine": 21, - "sourceId": "", - "startColumn": 26, - "startLine": 21 - }, - "table": "addressTable" - }, - "tableAlias": "addressTable" - }, - { - "_type": "column", - "column": "ID", - "sourceInformation": { - "endColumn": 67, - "endLine": 21, - "sourceId": "", - "startColumn": 52, - "startLine": 21 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 64, - "endLine": 21, - "sourceId": "", - "startColumn": 52, - "startLine": 21 - }, - "table": "locationTable" - }, - "tableAlias": "locationTable" - } - ], - "sourceInformation": { - "endColumn": 67, - "endLine": 21, - "sourceId": "", - "startColumn": 50, - "startLine": 21 - } - }, - "sourceInformation": { - "endColumn": 68, - "endLine": 21, - "sourceId": "", - "startColumn": 4, - "startLine": 21 - } - } - ], - "name": "db", - "package": "meta::dataquality", - "schemas": [ - { - "name": "default", - "sourceInformation": { - "endColumn": 1, - "endLine": 22, - "sourceId": "", - "startColumn": 1, - "startLine": 14 - }, - "tables": [ - { - "columns": [ - { - "name": "ID", - "nullable": false, - "sourceInformation": { - "endColumn": 40, - "endLine": 16, - "sourceId": "", - "startColumn": 23, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "FIRSTNAME", - "nullable": true, - "sourceInformation": { - "endColumn": 64, - "endLine": 16, - "sourceId": "", - "startColumn": 43, - "startLine": 16 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - }, - { - "name": "LASTNAME", - "nullable": true, - "sourceInformation": { - "endColumn": 87, - "endLine": 16, - "sourceId": "", - "startColumn": 67, - "startLine": 16 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - }, - { - "name": "AGE", - "nullable": true, - "sourceInformation": { - "endColumn": 96, - "endLine": 16, - "sourceId": "", - "startColumn": 90, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "ADDRESSID", - "nullable": true, - "sourceInformation": { - "endColumn": 111, - "endLine": 16, - "sourceId": "", - "startColumn": 99, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "FIRMID", - "nullable": true, - "sourceInformation": { - "endColumn": 123, - "endLine": 16, - "sourceId": "", - "startColumn": 114, - "startLine": 16 - }, - "type": { - "_type": "Integer" - } - } - ], - "milestoning": [], - "name": "personTable", - "primaryKey": [ - "ID" - ], - "sourceInformation": { - "endColumn": 124, - "endLine": 16, - "sourceId": "", - "startColumn": 4, - "startLine": 16 - } - }, - { - "columns": [ - { - "name": "ID", - "nullable": false, - "sourceInformation": { - "endColumn": 41, - "endLine": 17, - "sourceId": "", - "startColumn": 24, - "startLine": 17 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "LOCATIONID", - "nullable": true, - "sourceInformation": { - "endColumn": 57, - "endLine": 17, - "sourceId": "", - "startColumn": 44, - "startLine": 17 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "TYPE", - "nullable": true, - "sourceInformation": { - "endColumn": 67, - "endLine": 17, - "sourceId": "", - "startColumn": 60, - "startLine": 17 - }, - "type": { - "_type": "Integer" - } - } - ], - "milestoning": [], - "name": "addressTable", - "primaryKey": [ - "ID" - ], - "sourceInformation": { - "endColumn": 68, - "endLine": 17, - "sourceId": "", - "startColumn": 4, - "startLine": 17 - } - }, - { - "columns": [ - { - "name": "ID", - "nullable": false, - "sourceInformation": { - "endColumn": 42, - "endLine": 18, - "sourceId": "", - "startColumn": 25, - "startLine": 18 - }, - "type": { - "_type": "Integer" - } - }, - { - "name": "STREET", - "nullable": true, - "sourceInformation": { - "endColumn": 63, - "endLine": 18, - "sourceId": "", - "startColumn": 45, - "startLine": 18 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - }, - { - "name": "LOCALITY", - "nullable": true, - "sourceInformation": { - "endColumn": 86, - "endLine": 18, - "sourceId": "", - "startColumn": 66, - "startLine": 18 - }, - "type": { - "_type": "Varchar", - "size": 200 - } - } - ], - "milestoning": [], - "name": "locationTable", - "primaryKey": [ - "ID" - ], - "sourceInformation": { - "endColumn": 87, - "endLine": 18, - "sourceId": "", - "startColumn": 4, - "startLine": 18 - } - } - ], - "views": [] - } - ], - "sourceInformation": { - "endColumn": 1, - "endLine": 22, - "sourceId": "", - "startColumn": 1, - "startLine": 14 - }, - "stereotypes": [] - }, - { - "_type": "mapping", - "associationMappings": [], - "classMappings": [ - { - "_type": "relational", - "class": "meta::dataquality::Person", - "classSourceInformation": { - "endColumn": 28, - "endLine": 29, - "sourceId": "", - "startColumn": 4, - "startLine": 29 - }, - "distinct": false, - "groupBy": [], - "primaryKey": [], - "propertyMappings": [ - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Person", - "property": "name", - "sourceInformation": { - "endColumn": 10, - "endLine": 31, - "sourceId": "", - "startColumn": 7, - "startLine": 31 - } - }, - "relationalOperation": { - "_type": "column", - "column": "FIRSTNAME", - "sourceInformation": { - "endColumn": 57, - "endLine": 31, - "sourceId": "", - "startColumn": 14, - "startLine": 31 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 47, - "endLine": 31, - "sourceId": "", - "startColumn": 37, - "startLine": 31 - }, - "table": "personTable" - }, - "tableAlias": "personTable" - }, - "sourceInformation": { - "endColumn": 57, - "endLine": 31, - "sourceId": "", - "startColumn": 12, - "startLine": 31 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Person", - "property": "age", - "sourceInformation": { - "endColumn": 9, - "endLine": 32, - "sourceId": "", - "startColumn": 7, - "startLine": 32 - } - }, - "relationalOperation": { - "_type": "column", - "column": "AGE", - "sourceInformation": { - "endColumn": 50, - "endLine": 32, - "sourceId": "", - "startColumn": 13, - "startLine": 32 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 46, - "endLine": 32, - "sourceId": "", - "startColumn": 36, - "startLine": 32 - }, - "table": "personTable" - }, - "tableAlias": "personTable" - }, - "sourceInformation": { - "endColumn": 50, - "endLine": 32, - "sourceId": "", - "startColumn": 11, - "startLine": 32 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Person", - "property": "addresses", - "sourceInformation": { - "endColumn": 15, - "endLine": 33, - "sourceId": "", - "startColumn": 7, - "startLine": 33 - } - }, - "relationalOperation": { - "_type": "elemtWithJoins", - "joins": [ - { - "db": "meta::dataquality::db", - "name": "Address_Person", - "sourceInformation": { - "endColumn": 56, - "endLine": 33, - "sourceId": "", - "startColumn": 42, - "startLine": 33 - } - } - ], - "sourceInformation": { - "endColumn": 56, - "endLine": 33, - "sourceId": "", - "startColumn": 19, - "startLine": 33 - } - }, - "sourceInformation": { - "endColumn": 56, - "endLine": 33, - "sourceId": "", - "startColumn": 17, - "startLine": 33 - } - } - ], - "root": false, - "sourceInformation": { - "endColumn": 4, - "endLine": 34, - "sourceId": "", - "startColumn": 4, - "startLine": 29 - } - }, - { - "_type": "relational", - "class": "meta::dataquality::Address", - "classSourceInformation": { - "endColumn": 29, - "endLine": 36, - "sourceId": "", - "startColumn": 4, - "startLine": 36 - }, - "distinct": false, - "groupBy": [], - "primaryKey": [], - "propertyMappings": [ - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Address", - "property": "addressId", - "sourceInformation": { - "endColumn": 15, - "endLine": 38, - "sourceId": "", - "startColumn": 7, - "startLine": 38 - } - }, - "relationalOperation": { - "_type": "column", - "column": "ID", - "sourceInformation": { - "endColumn": 56, - "endLine": 38, - "sourceId": "", - "startColumn": 19, - "startLine": 38 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 53, - "endLine": 38, - "sourceId": "", - "startColumn": 42, - "startLine": 38 - }, - "table": "addressTable" - }, - "tableAlias": "addressTable" - }, - "sourceInformation": { - "endColumn": 56, - "endLine": 38, - "sourceId": "", - "startColumn": 17, - "startLine": 38 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Address", - "property": "location", - "sourceInformation": { - "endColumn": 14, - "endLine": 39, - "sourceId": "", - "startColumn": 7, - "startLine": 39 - } - }, - "relationalOperation": { - "_type": "elemtWithJoins", - "joins": [ - { - "db": "meta::dataquality::db", - "name": "Address_Location", - "sourceInformation": { - "endColumn": 57, - "endLine": 39, - "sourceId": "", - "startColumn": 41, - "startLine": 39 - } - } - ], - "sourceInformation": { - "endColumn": 57, - "endLine": 39, - "sourceId": "", - "startColumn": 18, - "startLine": 39 - } - }, - "sourceInformation": { - "endColumn": 57, - "endLine": 39, - "sourceId": "", - "startColumn": 16, - "startLine": 39 - } - } - ], - "root": false, - "sourceInformation": { - "endColumn": 4, - "endLine": 40, - "sourceId": "", - "startColumn": 4, - "startLine": 36 - } - }, - { - "_type": "relational", - "class": "meta::dataquality::Location", - "classSourceInformation": { - "endColumn": 30, - "endLine": 42, - "sourceId": "", - "startColumn": 4, - "startLine": 42 - }, - "distinct": false, - "groupBy": [], - "primaryKey": [], - "propertyMappings": [ - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Location", - "property": "street", - "sourceInformation": { - "endColumn": 12, - "endLine": 44, - "sourceId": "", - "startColumn": 7, - "startLine": 44 - } - }, - "relationalOperation": { - "_type": "column", - "column": "STREET", - "sourceInformation": { - "endColumn": 58, - "endLine": 44, - "sourceId": "", - "startColumn": 16, - "startLine": 44 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 51, - "endLine": 44, - "sourceId": "", - "startColumn": 39, - "startLine": 44 - }, - "table": "locationTable" - }, - "tableAlias": "locationTable" - }, - "sourceInformation": { - "endColumn": 58, - "endLine": 44, - "sourceId": "", - "startColumn": 14, - "startLine": 44 - } - }, - { - "_type": "relationalPropertyMapping", - "property": { - "class": "meta::dataquality::Location", - "property": "locality", - "sourceInformation": { - "endColumn": 14, - "endLine": 45, - "sourceId": "", - "startColumn": 7, - "startLine": 45 - } - }, - "relationalOperation": { - "_type": "column", - "column": "LOCALITY", - "sourceInformation": { - "endColumn": 62, - "endLine": 45, - "sourceId": "", - "startColumn": 18, - "startLine": 45 - }, - "table": { - "_type": "Table", - "database": "meta::dataquality::db", - "mainTableDb": "meta::dataquality::db", - "schema": "default", - "sourceInformation": { - "endColumn": 53, - "endLine": 45, - "sourceId": "", - "startColumn": 41, - "startLine": 45 - }, - "table": "locationTable" - }, - "tableAlias": "locationTable" - }, - "sourceInformation": { - "endColumn": 62, - "endLine": 45, - "sourceId": "", - "startColumn": 16, - "startLine": 45 - } - } - ], - "root": false, - "sourceInformation": { - "endColumn": 4, - "endLine": 46, - "sourceId": "", - "startColumn": 4, - "startLine": 42 - } - } - ], - "enumerationMappings": [], - "includedMappings": [], - "name": "dataqualitymappings", - "package": "meta::dataquality", - "sourceInformation": { - "endColumn": 1, - "endLine": 47, - "sourceId": "", - "startColumn": 1, - "startLine": 26 - }, - "tests": [] - }, - { - "_type": "runtime", - "name": "DataQualityRuntime", - "package": "meta::dataquality", - "runtimeValue": { - "_type": "engineRuntime", - "connectionStores": [], - "connections": [ - { - "sourceInformation": { - "endColumn": 5, - "endLine": 61, - "sourceId": "", - "startColumn": 5, - "startLine": 58 - }, - "store": { - "path": "meta::dataquality::db", - "sourceInformation": { - "endColumn": 25, - "endLine": 58, - "sourceId": "", - "startColumn": 5, - "startLine": 58 - }, - "type": "STORE" - }, - "storeConnections": [ - { - "connection": { - "_type": "connectionPointer", - "connection": "meta::dataquality::H2", - "sourceInformation": { - "endColumn": 41, - "endLine": 60, - "sourceId": "", - "startColumn": 21, - "startLine": 60 - } - }, - "id": "connection_1", - "sourceInformation": { - "endColumn": 41, - "endLine": 60, - "sourceId": "", - "startColumn": 7, - "startLine": 60 - } - } - ] - } - ], - "mappings": [ - { - "path": "meta::dataquality::dataqualitymappings", - "sourceInformation": { - "endColumn": 42, - "endLine": 54, - "sourceId": "", - "startColumn": 5, - "startLine": 54 - }, - "type": "MAPPING" - } - ], - "sourceInformation": { - "endColumn": 1, - "endLine": 63, - "sourceId": "", - "startColumn": 1, - "startLine": 50 - } - }, - "sourceInformation": { - "endColumn": 1, - "endLine": 63, - "sourceId": "", - "startColumn": 1, - "startLine": 50 - } - }, - { - "_type": "class", - "constraints": [ - { - "functionDefinition": { - "_type": "lambda", - "body": [ - { - "_type": "func", - "function": "greaterThanEqual", - "parameters": [ - { - "_type": "property", - "parameters": [ - { - "_type": "var", - "name": "this", - "sourceInformation": { - "endColumn": 25, - "endLine": 70, - "sourceId": "", - "startColumn": 21, - "startLine": 70 - } - } - ], - "property": "age", - "sourceInformation": { - "endColumn": 29, - "endLine": 70, - "sourceId": "", - "startColumn": 27, - "startLine": 70 - } - }, - { - "_type": "integer", - "sourceInformation": { - "endColumn": 35, - "endLine": 70, - "sourceId": "", - "startColumn": 34, - "startLine": 70 - }, - "value": 18 - } - ], - "sourceInformation": { - "endColumn": 35, - "endLine": 70, - "sourceId": "", - "startColumn": 31, - "startLine": 70 - } - } - ], - "parameters": [] - }, - "name": "mustBeOfLegalAge", - "sourceInformation": { - "endColumn": 35, - "endLine": 70, - "sourceId": "", - "startColumn": 3, - "startLine": 70 - } - } - ], - "name": "Person", - "originalMilestonedProperties": [], - "package": "meta::dataquality", - "properties": [ - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "name", - "propertyTypeSourceInformation": { - "endColumn": 16, - "endLine": 73, - "sourceId": "", - "startColumn": 11, - "startLine": 73 - }, - "sourceInformation": { - "endColumn": 20, - "endLine": 73, - "sourceId": "", - "startColumn": 4, - "startLine": 73 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "age", - "propertyTypeSourceInformation": { - "endColumn": 16, - "endLine": 74, - "sourceId": "", - "startColumn": 10, - "startLine": 74 - }, - "sourceInformation": { - "endColumn": 20, - "endLine": 74, - "sourceId": "", - "startColumn": 4, - "startLine": 74 - }, - "stereotypes": [], - "taggedValues": [], - "type": "Integer" - }, - { - "multiplicity": { - "lowerBound": 0 - }, - "name": "addresses", - "propertyTypeSourceInformation": { - "endColumn": 41, - "endLine": 75, - "sourceId": "", - "startColumn": 16, - "startLine": 75 - }, - "sourceInformation": { - "endColumn": 45, - "endLine": 75, - "sourceId": "", - "startColumn": 4, - "startLine": 75 - }, - "stereotypes": [], - "taggedValues": [], - "type": "meta::dataquality::Address" - } - ], - "qualifiedProperties": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 76, - "sourceId": "", - "startColumn": 1, - "startLine": 68 - }, - "stereotypes": [], - "superTypes": [], - "taggedValues": [] - }, - { - "_type": "class", - "constraints": [], - "name": "Address", - "originalMilestonedProperties": [], - "package": "meta::dataquality", - "properties": [ - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "location", - "propertyTypeSourceInformation": { - "endColumn": 40, - "endLine": 80, - "sourceId": "", - "startColumn": 14, - "startLine": 80 - }, - "sourceInformation": { - "endColumn": 44, - "endLine": 80, - "sourceId": "", - "startColumn": 4, - "startLine": 80 - }, - "stereotypes": [], - "taggedValues": [], - "type": "meta::dataquality::Location" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "locationStreet", - "propertyTypeSourceInformation": { - "endColumn": 25, - "endLine": 81, - "sourceId": "", - "startColumn": 20, - "startLine": 81 - }, - "sourceInformation": { - "endColumn": 29, - "endLine": 81, - "sourceId": "", - "startColumn": 4, - "startLine": 81 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "addressId", - "propertyTypeSourceInformation": { - "endColumn": 20, - "endLine": 82, - "sourceId": "", - "startColumn": 15, - "startLine": 82 - }, - "sourceInformation": { - "endColumn": 24, - "endLine": 82, - "sourceId": "", - "startColumn": 4, - "startLine": 82 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - } - ], - "qualifiedProperties": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 83, - "sourceId": "", - "startColumn": 1, - "startLine": 78 - }, - "stereotypes": [], - "superTypes": [], - "taggedValues": [] - }, - { - "_type": "class", - "constraints": [], - "name": "Location", - "originalMilestonedProperties": [], - "package": "meta::dataquality", - "properties": [ - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "street", - "propertyTypeSourceInformation": { - "endColumn": 17, - "endLine": 87, - "sourceId": "", - "startColumn": 12, - "startLine": 87 - }, - "sourceInformation": { - "endColumn": 21, - "endLine": 87, - "sourceId": "", - "startColumn": 4, - "startLine": 87 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - }, - { - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "locality", - "propertyTypeSourceInformation": { - "endColumn": 19, - "endLine": 88, - "sourceId": "", - "startColumn": 14, - "startLine": 88 - }, - "sourceInformation": { - "endColumn": 23, - "endLine": 88, - "sourceId": "", - "startColumn": 4, - "startLine": 88 - }, - "stereotypes": [], - "taggedValues": [], - "type": "String" - } - ], - "qualifiedProperties": [], - "sourceInformation": { - "endColumn": 1, - "endLine": 89, - "sourceId": "", - "startColumn": 1, - "startLine": 85 - }, - "stereotypes": [], - "superTypes": [], - "taggedValues": [] - }, - { - "_type": "dataQualityValidation", - "context": { - "_type": "mappingAndRuntimeDataQualityExecutionContext", - "_type": "mappingAndRuntimeDataQualityExecutionContext", - "mapping": { - "path": "meta::dataquality::dataqualitymappings", - "sourceInformation": { - "endColumn": 73, - "endLine": 94, - "sourceId": "", - "startColumn": 36, - "startLine": 94 - }, - "type": "MAPPING" - }, - "runtime": { - "path": "meta::dataquality::DataQualityRuntime", - "sourceInformation": { - "endColumn": 112, - "endLine": 94, - "sourceId": "", - "startColumn": 76, - "startLine": 94 - }, - "type": "RUNTIME" - } - }, - "dataQualityRootGraphFetchTree": { - "_type": "dataQualityRootGraphFetchTree", - "_type": "dataQualityRootGraphFetchTree", - "class": "meta::dataquality::Person", - "constraints": [ - "mustBeOfLegalAge" - ], - "sourceInformation": { - "endColumn": 31, - "endLine": 97, - "sourceId": "", - "startColumn": 7, - "startLine": 97 - }, - "subTrees": [ - { - "_type": "dataQualityPropertyGraphFetchTree", - "_type": "dataQualityPropertyGraphFetchTree", - "constraints": [], - "parameters": [], - "property": "name", - "sourceInformation": { - "endColumn": 12, - "endLine": 98, - "sourceId": "", - "startColumn": 9, - "startLine": 98 - }, - "subTrees": [], - "subTypeTrees": [] - } - ], - "subTypeTrees": [] - }, - "filter": { - "_type": "lambda", - "body": [ - { - "_type": "func", - "function": "equal", - "parameters": [ - { - "_type": "property", - "parameters": [ - { - "_type": "var", - "name": "p", - "sourceInformation": { - "endColumn": 47, - "endLine": 95, - "sourceId": "", - "startColumn": 46, - "startLine": 95 - } - } - ], - "property": "name", - "sourceInformation": { - "endColumn": 52, - "endLine": 95, - "sourceId": "", - "startColumn": 49, - "startLine": 95 - } - }, - { - "_type": "string", - "sourceInformation": { - "endColumn": 60, - "endLine": 95, - "sourceId": "", - "startColumn": 55, - "startLine": 95 - }, - "value": "John" - } - ], - "sourceInformation": { - "endColumn": 54, - "endLine": 95, - "sourceId": "", - "startColumn": 53, - "startLine": 95 - } - } - ], - "parameters": [ - { - "_type": "var", - "class": "meta::dataquality::Person", - "multiplicity": { - "lowerBound": 1, - "upperBound": 1 - }, - "name": "p", - "sourceInformation": { - "endColumn": 39, - "endLine": 95, - "sourceId": "", - "startColumn": 15, - "startLine": 95 - } - } - ], - "sourceInformation": { - "endColumn": 60, - "endLine": 95, - "sourceId": "", - "startColumn": 44, - "startLine": 95 - } - }, - "name": "PersonDataQualityValidation", - "package": "meta::dataquality", - "sourceInformation": { - "endColumn": 1, - "endLine": 101, - "sourceId": "", - "startColumn": 1, - "startLine": 92 - }, - "stereotypes": [], - "taggedValues": [] - }, - { - "_type": "sectionIndex", - "name": "SectionIndex", - "package": "__internal__", - "sections": [ - { - "_type": "importAware", - "elements": [], - "imports": [], - "parserName": "Pure", - "sourceInformation": { - "endColumn": 8, - "endLine": 1, - "sourceId": "", - "startColumn": 1, - "startLine": 1 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::H2" - ], - "imports": [], - "parserName": "Connection", - "sourceInformation": { - "endColumn": 2, - "endLine": 13, - "sourceId": "", - "startColumn": 8, - "startLine": 2 - } - }, - { - "_type": "default", - "elements": [ - "meta::dataquality::db" - ], - "parserName": "Relational", - "sourceInformation": { - "endColumn": 1, - "endLine": 25, - "sourceId": "", - "startColumn": 1, - "startLine": 14 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::dataqualitymappings" - ], - "imports": [], - "parserName": "Mapping", - "sourceInformation": { - "endColumn": 2, - "endLine": 49, - "sourceId": "", - "startColumn": 1, - "startLine": 26 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::DataQualityRuntime" - ], - "imports": [], - "parserName": "Runtime", - "sourceInformation": { - "endColumn": 1, - "endLine": 67, - "sourceId": "", - "startColumn": 1, - "startLine": 50 - } - }, - { - "_type": "importAware", - "elements": [ - "meta::dataquality::Person", - "meta::dataquality::Address", - "meta::dataquality::Location" - ], - "imports": [], - "parserName": "Pure", - "sourceInformation": { - "endColumn": 2, - "endLine": 91, - "sourceId": "", - "startColumn": 1, - "startLine": 68 - } - }, - { - "_type": "default", - "elements": [ - "meta::dataquality::PersonDataQualityValidation" - ], - "parserName": "DataQualityValidation", - "sourceInformation": { - "endColumn": 1, - "endLine": 103, - "sourceId": "", - "startColumn": 1, - "startLine": 92 - } - } - ] - } - ] -} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-grammar/pom.xml b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-grammar/pom.xml index af1039d042e..a7636c25f59 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-grammar/pom.xml +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-grammar/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-dataquality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-protocol/pom.xml b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-protocol/pom.xml index e4267759eab..9cf3f2b7f14 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-protocol/pom.xml +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-protocol/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-dataquality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/pom.xml b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/pom.xml index 24695e8624c..0854f7e998a 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/pom.xml +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-dataquality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -85,6 +85,11 @@ legend-engine-pure-platform-dsl-graph-java ${project.version} + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler + ${project.version} + org.finos.legend.pure legend-pure-m2-store-relational-pure @@ -177,6 +182,11 @@ org.finos.legend.pure legend-pure-m2-store-relational-pure + runtime + + + org.finos.legend.pure + legend-pure-m2-dsl-graph-pure org.finos.legend.engine @@ -193,6 +203,7 @@ org.finos.legend.pure legend-pure-m2-dsl-mapping-pure + runtime org.finos.legend.pure @@ -224,6 +235,16 @@ legend-engine-xt-dataquality-pure ${project.version} + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler + ${project.version} + runtime + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-unclassified + junit @@ -244,6 +265,16 @@ jackson-core test + + org.finos.legend.engine + legend-engine-xt-dataquality-compiler + runtime + + + org.finos.legend.engine + legend-engine-xt-relationalStore-grammar + runtime + \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test.definition.json b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test.definition.json index 3ada292dae1..3e605360a54 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test.definition.json +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test.definition.json @@ -5,11 +5,13 @@ "core", "core_relational", "core_data_space_metamodel", + "core_functions_unclassified", "platform", "platform_dsl_store", "platform_dsl_graph", "platform_dsl_mapping", "platform_store_relational", - "core_dataquality" + "core_dataquality", + "core_external_compiler" ] } \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure index 3f00dcdf09a..f02b9552eda 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure @@ -1,118 +1,173 @@ -import meta::pure::router::platform::execution::*; -import meta::pure::graphFetch::*; -import meta::external::dataquality::*; +import meta::pure::graphFetch::execution::*; import meta::external::dataquality::tests::*; -import meta::pure::metamodel::dataSpace::*; -import meta::pure::mapping::*; -import meta::core::runtime::*; -import meta::external::store::relational::tests::*; -import meta::relational::metamodel::*; -import meta::pure::executionPlan::*; -import meta::relational::tests::milestoning::*; -import meta::pure::profiles::*; -import meta::pure::metamodel::serialization::grammar::*; +import meta::external::dataquality::tests::domain::*; - -function <> meta::external::dataquality::tests::testLambdaGeneration():Boolean[1] -{ let dqRootConstraints = meta::external::dataquality::tests::Person->getAllTypeGeneralisations()->filter(x| $x->instanceOf(ElementWithConstraints))->cast(@ElementWithConstraints).constraints->filter(x| $x.name == 'addressIDGreaterThan2'); - - let validationTree = ^DataQualityRootGraphFetchTree( - class=meta::external::dataquality::tests::Person, - constraints=$dqRootConstraints->at(0), - subTrees=meta::external::dataquality::tests::Person->hierarchicalProperties()->filter(p | $p->isPrimitiveValueProperty())->filter(p| $p.name=='age')->map(p | ^DataQualityPropertyGraphFetchTree(property=$p)) - ); - let filter = p:Person[1]| $p.name=='John'; - let dataquality = ^DataQuality(validationTree=$validationTree, - context=^meta::external::dataquality::MappingAndRuntimeDataQualityExecutionContext(runtime=^meta::core::runtime::EngineRuntime(connectionStores = testDatabaseConnection(meta::relational::tests::db, [])), mapping=meta::external::dataquality::tests::dqValidationPersonMapping), - filter=$filter); - - // fetch lambda from DQ func; - let dqLambda = meta::external::dataquality::executeDataQualityValidation($dataquality, []); - assert($dqLambda->isNotEmpty()); +function <> meta::external::dataquality::tests::testLambdaGenerationMultipleConstraints():Boolean[1] +{ + doTest('$[' + + ' meta::external::dataquality::tests::domain::Person{' + + ' name,' + + ' addresses{' + + ' addressId' + + ' }' + + ' }' + + ' ]$', {|Person.all() + ->filter(x|(!(($x.age >= 0)) || (!(($x.age >= 18)) || !(($x.name->length() < 1000))))) + ->graphFetchChecked(#{ + Person { + addresses { + addressId + }, + age, + name + } + }#)->serialize(#{ + Person { + addresses { + addressId + }, + age, + name + } + }#) + }, true, false) } -function <> meta::external::dataquality::tests::testLambdaGeneration_OnlyStructuralConstraints():Boolean[1] -{ let dqRootConstraints = meta::external::dataquality::tests::Person->getAllTypeGeneralisations()->filter(x| $x->instanceOf(ElementWithConstraints))->cast(@ElementWithConstraints).constraints->filter(x| $x.name == 'addressIDGreaterThan2'); - - let validationTree = ^DataQualityRootGraphFetchTree( - class=meta::external::dataquality::tests::Person, - constraints=[], - subTrees=meta::external::dataquality::tests::Person->hierarchicalProperties()->filter(p | $p->isPrimitiveValueProperty())->filter(p| $p.name=='age')->map(p | ^DataQualityPropertyGraphFetchTree(property=$p)) - ); - let filter = p:Person[1]| $p.name=='John'; - let dataquality = ^DataQuality(validationTree=$validationTree, - context=^meta::external::dataquality::MappingAndRuntimeDataQualityExecutionContext(runtime=^meta::core::runtime::EngineRuntime(connectionStores = testDatabaseConnection(meta::relational::tests::db, [])), mapping=meta::external::dataquality::tests::dqValidationPersonMapping), - filter=$filter); - - let dqLambda = meta::external::dataquality::executeDataQualityValidation($dataquality, []); - assert($dqLambda->isNotEmpty()); +function <> meta::external::dataquality::tests::testLambdaGenerationNonTemporalToBusinessTemporal():Boolean[1] +{ + doTest('$[' + + ' meta::external::dataquality::tests::domain::NonTemporal{' + + ' name,' + + ' businessTemporal{' + + ' name' + + ' }' + + ' }' + + ' ]$', {businessDate:Date[1] | meta::external::dataquality::tests::domain::NonTemporal.all() + ->graphFetchChecked(#{ + NonTemporal { + name, + businessTemporal($businessDate) { + name + } + } + }#)->serialize(#{ + NonTemporal { + name, + businessTemporal($businessDate) { + name + } + } + }#) + }) } -function <> meta::external::dataquality::tests::testMetadataGeneration():Boolean[1] -{ let dqRootConstraints = meta::external::dataquality::tests::Person->getAllTypeGeneralisations()->filter(x| $x->instanceOf(ElementWithConstraints))->cast(@ElementWithConstraints).constraints->filter(x| $x.name == 'addressIDGreaterThan2' || $x.name == 'nameMustNotBeBlank'); - - let validationTree = ^DataQualityRootGraphFetchTree( - class=meta::external::dataquality::tests::Person, - constraints=$dqRootConstraints, - subTrees=meta::external::dataquality::tests::Person->hierarchicalProperties()->filter(p | $p->isPrimitiveValueProperty()->not())->filter(p| $p.name=='addresses')->map(p | ^DataQualityPropertyGraphFetchTree(property=$p, - subTrees=meta::external::dataquality::tests::Address->hierarchicalProperties()->filter(p | $p->isPrimitiveValueProperty())->filter(p| $p.name=='addressId')->map(p | ^DataQualityPropertyGraphFetchTree(property=$p)))) - ); - let filter = p:Person[1]| $p.name=='John'; - let dataquality = ^DataQuality(validationTree=$validationTree, - context=^meta::external::dataquality::MappingAndRuntimeDataQualityExecutionContext(runtime=^meta::core::runtime::EngineRuntime(connectionStores = testDatabaseConnection(meta::relational::tests::db, [])), mapping=meta::external::dataquality::tests::dqValidationPersonMapping), - filter=$filter); - - let dqMetadata = meta::external::dataquality::generateDQMetaDataForDQValidation($dataquality); - assert($dqMetadata->isNotEmpty()); +function <> meta::external::dataquality::tests::testLambdaGenerationNonTemporalToProcessingTemporal():Boolean[1] +{ + doTest('$[' + + ' meta::external::dataquality::tests::domain::NonTemporal{' + + ' name,' + + ' processingTemporal{' + + ' name' + + ' }' + + ' }' + + ' ]$', {processingDate:Date[1] | meta::external::dataquality::tests::domain::NonTemporal.all() + ->graphFetchChecked(#{ + NonTemporal { + name, + processingTemporal($processingDate) { + name + } + } + }#)->serialize(#{ + NonTemporal { + name, + processingTemporal($processingDate) { + name + } + } + }#) + }) } - - - -// -------------------------------------- Test Setup -------------------------------------------------------------------------// -// relational mappings -Class meta::external::dataquality::tests::Person -[ - nameMustNotBeBlank: $this.name->length() > 0, - ageMustBePositive: $this.age > 0, - nameAtLeast4Chars: $this.name->length() > 4, - ageMustBeGreaterThan10: $this.age > 100, - //addressIDGreaterThan1: $this.addresses->filter(a | $a.addressId > 1)->isNotEmpty(), - addressIDGreaterThan2: $this.addresses->filter(a | $a.addressId > 2)->isNotEmpty() -] +function <> meta::external::dataquality::tests::testLambdaGenerationNonTemporalToBusinessAndProcessingTemporal():Boolean[1] { - name : String[1]; - age : Integer[1]; - addresses : meta::external::dataquality::tests::Address[*]; + doTest('$[' + + ' meta::external::dataquality::tests::domain::NonTemporal{' + + ' name,' + + ' processingTemporal{' + + ' name' + + ' },' + + ' businessTemporal{' + + ' name' + + ' }' + + ' }' + + ' ]$', {processingDate:Date[1], businessDate:Date[1] | meta::external::dataquality::tests::domain::NonTemporal.all() + ->graphFetchChecked(#{ + NonTemporal { + name, + processingTemporal($processingDate) { + name + }, + businessTemporal($businessDate) { + name + } + } + }#)->serialize(#{ + NonTemporal { + name, + processingTemporal($processingDate) { + name + }, + businessTemporal($businessDate) { + name + } + } + }#) + }) } -Class meta::external::dataquality::tests::Address -[ - addressIDMustNotBeBlank: $this.addressId > 0 -] +function <> meta::external::dataquality::tests::testLambdaGenerationNonTemporalToBiTemporal():Boolean[1] { - // location: Location[1]; - // locationStreet: String[1]; - addressId: Integer[1]; + doTest('$[' + + ' meta::external::dataquality::tests::domain::NonTemporal{' + + ' name,' + + ' biTemporal{' + + ' name' + + ' }' + + ' }' + + ' ]$', {processingDate:Date[1], businessDate:Date[1] | meta::external::dataquality::tests::domain::NonTemporal.all() + ->graphFetchChecked(#{ + NonTemporal { + name, + biTemporal($processingDate, $businessDate) { + name + } + } + }#)->serialize(#{ + NonTemporal { + name, + biTemporal($processingDate, $businessDate) { + name + } + } + }#) + }) } -###Mapping -import meta::relational::validation::complex::*; - -Mapping meta::external::dataquality::tests::dqValidationPersonMapping -( - meta::external::dataquality::tests::Person : Relational - { - // ~filter [db] (INNER)@Address_Person | [db] ActiveAddressFilter - name : [db]personTable.FIRSTNAME, - age : [db]personTable.AGE, - addresses : [db]@Address_Person - } - meta::external::dataquality::tests::Address : Relational - { - // ~filter [db] (INNER)@Address_Location | [db] LocationStreetLengthLessThan10 - addressId : [db]addressTable.ID - // location : [db]@Address_Location - } - -) +function <> meta::external::dataquality::tests::testMetadata():Boolean[1] +{ + let dq = meta::external::dataquality::tests::loadDataQuality('$[' + + ' meta::external::dataquality::tests::domain::NonTemporal{' + + ' name,' + + ' biTemporal{' + + ' name' + + ' }' + + ' }' + + ' ]$'); + + + let metadata = meta::external::dataquality::generateDQMetaDataForDQValidation($dq); + + //TODO assert on structure. + assert($metadata->isNotEmpty()); +} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_model.pure b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_model.pure new file mode 100644 index 00000000000..03d7e955acf --- /dev/null +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_model.pure @@ -0,0 +1,113 @@ +###Relational +Database meta::external::dataquality::tests::domain::db +( + Table personTable + ( + ID INTEGER PRIMARY KEY, + FIRSTNAME VARCHAR(200), + LASTNAME VARCHAR(200), + AGE INTEGER, + ADDRESSID INTEGER, + FIRMID INTEGER + ) + Table addressTable + ( + ID INTEGER PRIMARY KEY, + LOCATIONID INTEGER, + TYPE INTEGER + ) + Table locationTable + ( + ID INTEGER PRIMARY KEY, + STREET VARCHAR(200), + LOCALITY VARCHAR(200) + ) + + Join Address_Person(addressTable.ID = personTable.ADDRESSID) + Join Address_Location(addressTable.LOCATIONID = locationTable.ID) +) + + +###Mapping +Mapping meta::external::dataquality::tests::domain::dataqualitymappings +( + meta::external::dataquality::tests::domain::Person: Relational + { + name: [meta::external::dataquality::tests::domain::db]personTable.FIRSTNAME, + age: [meta::external::dataquality::tests::domain::db]personTable.AGE, + addresses: [meta::external::dataquality::tests::domain::db]@Address_Person + } + meta::external::dataquality::tests::domain::Address: Relational + { + addressId: [meta::external::dataquality::tests::domain::db]addressTable.ID, + location: [meta::external::dataquality::tests::domain::db]@Address_Location + } + meta::external::dataquality::tests::domain::Location: Relational + { + street: [meta::external::dataquality::tests::domain::db]locationTable.STREET, + locality: [meta::external::dataquality::tests::domain::db]locationTable.LOCALITY + } +) + +###Pure +Class meta::external::dataquality::tests::domain::Person +[ + mustBeOfLegalAge: $this.age >= 18, + validNameLength: $this.name->length() < 1000, + ageMustBePositive: $this.age >= 0 +] +{ + name: String[1]; + age: Integer[1]; + addresses: meta::external::dataquality::tests::domain::Address[*]; +} + +Class meta::external::dataquality::tests::domain::Address +[ + validAddressId: $this.addressId->isNotEmpty() +] +{ + location: meta::external::dataquality::tests::domain::Location[1]; + locationStreet: String[1]; + addressId: String[1]; +} + +Class meta::external::dataquality::tests::domain::Location +{ + street: String[1]; + locality: String[1]; +} + + +Class meta::external::dataquality::tests::domain::NonTemporal +[ + nameLength: $this.name->length() > 1 +] +{ + name: String[1]; + businessTemporal: meta::external::dataquality::tests::domain::BusinessTemporal[0..1]; + processingTemporal: meta::external::dataquality::tests::domain::ProcessingTemporal[0..1]; + biTemporal: meta::external::dataquality::tests::domain::BiTemporalEntity[0..1]; +} + +Class <> meta::external::dataquality::tests::domain::BusinessTemporal +{ + name: String[1]; + parent: meta::external::dataquality::tests::domain::BusinessTemporal[0..1]; + nonTemporal: meta::external::dataquality::tests::domain::NonTemporal[0..1]; + processingTemporal: meta::external::dataquality::tests::domain::ProcessingTemporal[0..1]; +} + +Class <> meta::external::dataquality::tests::domain::ProcessingTemporal +{ + name: String[1]; + parent: meta::external::dataquality::tests::domain::ProcessingTemporal[0..1]; + nonTemporal: meta::external::dataquality::tests::domain::NonTemporal[0..1]; + businessTemporal: meta::external::dataquality::tests::domain::BusinessTemporal[0..1]; +} + +Class <> meta::external::dataquality::tests::domain::BiTemporalEntity +{ + name: String[1]; + nonTemporal: meta::external::dataquality::tests::domain::NonTemporal[0..1]; +} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_model_legend.txt b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_model_legend.txt new file mode 100644 index 00000000000..9dd40e90259 --- /dev/null +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_model_legend.txt @@ -0,0 +1,26 @@ +###Runtime +Runtime meta::external::dataquality::tests::domain::DataQualityRuntime +{ + mappings: + [ + meta::external::dataquality::tests::domain::dataqualitymappings + ]; + connections: + [ + meta::external::dataquality::tests::domain::db: + [ + connection_1: meta::external::dataquality::tests::domain::H2 + ] + ]; +} + +###Connection +RelationalDatabaseConnection meta::external::dataquality::tests::domain::H2 +{ + store: meta::external::dataquality::tests::domain::db; + type: H2; + specification: LocalH2 + { + }; + auth: DefaultH2; +} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_utils.pure b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_utils.pure new file mode 100644 index 00000000000..68b58560b6c --- /dev/null +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_utils.pure @@ -0,0 +1,78 @@ +import meta::pure::graphFetch::*; +import meta::pure::extension::*; +import meta::pure::metamodel::serialization::grammar::*; +import meta::external::dataquality::tests::*; +import meta::external::dataquality::*; + +function meta::external::dataquality::tests::loadDataQuality(tree:String[1]):DataQuality[1] +{ + let model = readFile('/core_dataquality_test/dataquality_test_model.pure')->toOne(); + let extra = readFile('/core_dataquality_test/dataquality_test_model_legend.txt')->toOne(); + + let dq = + '###DataQualityValidation\n' + + 'DataQualityValidation meta::external::dataquality::tests::domain::Validation' + + '{' + + ' context: fromMappingAndRuntime(meta::external::dataquality::tests::domain::dataqualitymappings, meta::external::dataquality::tests::domain::DataQualityRuntime);' + + ' validationTree: ' + $tree + ';' + + '}'; + + let code = $model + '\n' + $extra + '\n' + $dq; + + let compiled = meta::legend::compileLegendGrammar($code); + + $compiled->filter(c | $c->elementToPath() == 'meta::external::dataquality::tests::domain::Validation')->toOne()->cast(@DataQuality); +} + +function meta::external::dataquality::tests::doTest(tree:String[1], expected:FunctionDefinition[1]):Boolean[1] +{ + let dataQuality = loadDataQuality($tree); + + let actual = meta::external::dataquality::generateDataQualityQuery($dataQuality, [], false); + + assertLambdaAndJSONEquals($expected, $actual); +} + +function meta::external::dataquality::tests::doTest(tree:String[1], expected:FunctionDefinition[1], assertLambda:Boolean[1], assertJson:Boolean[1]):Boolean[1] +{ + let dataQuality = loadDataQuality($tree); + + let actual = meta::external::dataquality::generateDataQualityQuery($dataQuality, [], false); + + if ($assertLambda, | assertLambdaEquals($expected, $actual), | true); + if ($assertJson, | assertLambdaJSONEquals($expected, $actual), | true); +} + + + +function meta::external::dataquality::tests::assertLambdaAndJSONEquals(expected:FunctionDefinition[1], actual:LambdaFunction[1]): Boolean[1] +{ + assertLambdaEquals($expected, $actual); + assertLambdaJSONEquals($expected, $actual); +} + +function meta::external::dataquality::tests::assertLambdaEquals(expected:FunctionDefinition[1], actual:FunctionDefinition[1]): Boolean[1] +{ + let config = ^meta::pure::metamodel::serialization::grammar::Configuration + ( + fullPath = true, + extensions = ^meta::pure::metamodel::serialization::grammar::GrammarExtension( + extraInstanceValueHandlers = + [ + g:GraphFetchTree[1]| treeToString($g) + ] + ) + ); + + assertEquals($expected->printFunctionDefinition($config, ''), $actual->printFunctionDefinition($config, '')); +} + +function meta::external::dataquality::tests::assertLambdaJSONEquals(expected:FunctionDefinition[1], actual:FunctionDefinition[1]): Boolean[1] +{ + assertEquals($expected->functionJSON(), $actual->functionJSON()); +} + +function meta::external::dataquality::tests::functionJSON(func:FunctionDefinition[1]): String[1] +{ + $func->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::transformLambda(defaultExtensions())->meta::json::toJSON(100); +} \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/pom.xml b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/pom.xml index a32a7fe1aae..ef251ad5145 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/pom.xml +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-dataquality org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality.definition.json b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality.definition.json index 0195b4c6683..76b939b78f1 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality.definition.json +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality.definition.json @@ -5,6 +5,7 @@ "core", "core_relational", "core_data_space_metamodel", + "core_functions_unclassified", "platform", "platform_dsl_store", "platform_dsl_graph", diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality/generation/dataquality.pure b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality/generation/dataquality.pure index 919c7742e61..0683e1e5014 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality/generation/dataquality.pure +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure/src/main/resources/core_dataquality/generation/dataquality.pure @@ -14,15 +14,79 @@ import meta::pure::metamodel::constraint::*; import meta::pure::lineage::scanProperties::propertyTree::*; +Class meta::external::dataquality::MilestoningContext +{ + rootBusinessTemporal: Boolean[1]; + rootProcessingTemporal: Boolean[1]; + nonRootBusinessTemporal: Boolean[1]; + nonRootProcessingTemporal: Boolean[1]; + + businessTemporal(){ + $this.rootBusinessTemporal || $this.nonRootBusinessTemporal + }:Boolean[1]; + + processingTemporal(){ + $this.rootProcessingTemporal || $this.nonRootProcessingTemporal + }:Boolean[1]; +} + +function meta::external::dataquality::generateDataQualityQuery(dataquality:meta::external::dataquality::DataQuality[1], limit: Integer[*]): LambdaFunction[1] +{ + generateDataQualityQuery($dataquality, $limit, true); +} + + +function meta::external::dataquality::getMilestoningContext(tree:RootGraphFetchTree[1]): MilestoningContext[1] +{ + let properties = getAllProperties($tree); + let propertyTypes = $properties.genericType.rawType; + + ^MilestoningContext( + rootBusinessTemporal = $tree.class->meta::pure::milestoning::isBusinessTemporal(), + rootProcessingTemporal = $tree.class->meta::pure::milestoning::isProcessingTemporal(), + nonRootBusinessTemporal = $propertyTypes->exists(t | $t->meta::pure::milestoning::isBusinessTemporal()), + nonRootProcessingTemporal = $propertyTypes->exists(t | $t->meta::pure::milestoning::isProcessingTemporal()) + ); +} + +function meta::external::dataquality::addMilestoningParameters(tree:GraphFetchTree[1]):GraphFetchTree[1] +{ + $tree->match([ + p:PropertyGraphFetchTree[1] | + let parameters = if ($p.parameters->isEmpty(), + | let isBusinessTemporal = $p.property.genericType.rawType->toOne()->meta::pure::milestoning::isBusinessTemporal(); + let isProcessingTemporal = $p.property.genericType.rawType->toOne()->meta::pure::milestoning::isProcessingTemporal(); + getTemporalParameters($isProcessingTemporal, $isBusinessTemporal);, + | $p.parameters + ); + + ^$p( + subTrees = $p.subTrees->map(t | addMilestoningParameters($t)), + parameters = $parameters, + subTypeTrees = $p.subTypeTrees->map(t | addMilestoningParameters($t))->cast(@SubTypeGraphFetchTree) + );, + g:GraphFetchTree[1] | + ^$g( + subTrees = $g.subTrees->map(t | addMilestoningParameters($t)), + subTypeTrees = $g.subTypeTrees->map(t | addMilestoningParameters($t))->cast(@SubTypeGraphFetchTree) + ) + ]) +} -function meta::external::dataquality::executeDataQualityValidation(dataquality:meta::external::dataquality::DataQuality[1], limit: Integer[*]): LambdaFunction[1] +function meta::external::dataquality::generateDataQualityQuery(dataquality:meta::external::dataquality::DataQuality[1], limit: Integer[*], useFrom:Boolean[1]): LambdaFunction[1] { $dataquality.validationTree->validateTreeForNestedConstraints(true); + + let milestonedTree = $dataquality.validationTree->addMilestoningParameters(); + // 1. enrich tree with selected constraint properties - let enrichedTree = $dataquality.validationTree->ensureFunctionRequirementsForDataQuality($dataquality.validationTree.constraints, $dataquality.validationTree.class, [], true)->cast(@RootGraphFetchTree); + let enrichedTree = $milestonedTree->ensureFunctionRequirementsForDataQuality($dataquality.validationTree.constraints, $dataquality.validationTree.class, [], true)->cast(@RootGraphFetchTree); + + let milestoningContext = getMilestoningContext($enrichedTree); // 2. build query - let getAll = $dataquality.validationTree.class->createGetAllParameterized(); + let getAll = $dataquality.validationTree.class->createGetAll($milestoningContext.rootProcessingTemporal, $milestoningContext.rootBusinessTemporal); + let getExpr = if ($dataquality.filter->isNotEmpty(), | $dataquality.validationTree.class->generateFilterQuery($getAll, $dataquality.filter->toOne());, | $getAll); @@ -43,8 +107,8 @@ function meta::external::dataquality::executeDataQualityValidation(dataquality:m multiplicity = ZeroMany, importGroup=system::imports::coreImport); // 2.1 - let serialized = ^SimpleFunctionExpression(func=serialize_T_MANY__RootGraphFetchTree_1__String_1_, - functionName=serialize_T_MANY__RootGraphFetchTree_1__String_1_.name, + let serialized = ^SimpleFunctionExpression(func=serialize_Checked_MANY__RootGraphFetchTree_1__String_1_, + functionName=serialize_Checked_MANY__RootGraphFetchTree_1__String_1_.name, importGroup=system::imports::coreImport, genericType=^GenericType(rawType=String), multiplicity=ZeroMany, @@ -55,19 +119,15 @@ function meta::external::dataquality::executeDataQualityValidation(dataquality:m let deactivatedMapping = ^InstanceValue(values=$mappingAndRuntime.first->evaluateAndDeactivate(), genericType=^GenericType(rawType=Mapping), multiplicity=PureOne) ; let deactivatedRuntime = ^InstanceValue(values=$mappingAndRuntime.second->evaluateAndDeactivate(), genericType=^GenericType(rawType=NonExecutableValueSpecification), multiplicity=PureOne); - let from = ^SimpleFunctionExpression(func=from_T_m__Mapping_1__Runtime_1__T_m_, + let from = if ($useFrom, | ^SimpleFunctionExpression(func=from_T_m__Mapping_1__Runtime_1__T_m_, functionName=from_T_m__Mapping_1__Runtime_1__T_m_.name, importGroup=system::imports::coreImport, genericType=^GenericType(rawType=String), multiplicity=ZeroMany, - parametersValues=[$serialized, $deactivatedMapping, $deactivatedRuntime])->evaluateAndDeactivate(); + parametersValues=[$serialized, $deactivatedMapping, $deactivatedRuntime])->evaluateAndDeactivate(), | $serialized); // 3. build lambda - if ($dataquality.validationTree.class->meta::pure::milestoning::isTemporal(), - | $dataquality.validationTree.class->createLambdaParameterized($from), - | let lambda = {| ''}; - ^$lambda(expressionSequence = [$from]); - ); + createLambda($from, $milestoningContext.processingTemporal, $milestoningContext.businessTemporal); } function meta::external::dataquality::validateTreeForNestedConstraints(node:GraphFetchTree[1], isRoot:Boolean[1]): Boolean[1] @@ -127,118 +187,58 @@ function <> meta::external::dataquality::createGetAll(c: Clas ^$lambda(classifierGenericType=$classifierGenericType, expressionSequence = $getAllExpression).expressionSequence->at(0)->cast(@FunctionExpression); } -function <> meta::external::dataquality::createGetAllParameterized(c: Class[1]):FunctionExpression[1] -{ - if ($c->meta::pure::milestoning::isBiTemporal(), - | $c->createGetAllBiTemporal(), - | $c->createGetAllUniTemporal()); -} - -function <> meta::external::dataquality::createGetAllUniTemporal(c: Class[1]):FunctionExpression[1] +function <> meta::external::dataquality::getAllProperties(tree:GraphFetchTree[1]):AbstractProperty[*] { - if ($c->meta::pure::milestoning::isProcessingTemporal(), - | $c->createGetAllProcessingTemporal(), - | $c->createGetAllBusinessTemporal()); + let properties = $tree->match([ + p:PropertyGraphFetchTree[1] | $p.property, + g:GraphFetchTree[1] | [] + ]); + + $tree.subTrees->concatenate($tree.subTypeTrees) + ->map(t | $t->getAllProperties()) + ->concatenate($properties); } -function <> meta::external::dataquality::createLambdaParameterized(c: Class[1], from: SimpleFunctionExpression[1]):LambdaFunction[1] +function meta::external::dataquality::createLambda(body:ValueSpecification[1], processingTemporal:Boolean[1], businessTemporal:Boolean[1]):LambdaFunction[1] { - if ($c->meta::pure::milestoning::isBiTemporal(), - | $from->createLambdaBiTemporal(), - | $c->createLambdaUniTemporal($from)); -} + let parameters = getTemporalParameters($processingTemporal, $businessTemporal); + let functionType = ^FunctionType(returnMultiplicity = $body.multiplicity, returnType = $body.genericType, parameters = $parameters); -function <> meta::external::dataquality::createLambdaUniTemporal(c: Class[1], from: SimpleFunctionExpression[1]):LambdaFunction[1] -{ - if ($c->meta::pure::milestoning::isProcessingTemporal(), - | $from->createLambdaProcessingTemporal(), - | $from->createLambdaBusinessTemporal()); + let lambda = newLambdaFunction($functionType); + ^$lambda(expressionSequence = $body); } -function <> meta::external::dataquality::createLambdaProcessingTemporal(from: SimpleFunctionExpression[1]):LambdaFunction[1] +function <> meta::external::dataquality::createGetAll(c: Class[1], processingTemporal:Boolean[1], businessTemporal:Boolean[1]):FunctionExpression[1] { - let lambda = {processingDate: Date[1] | ''}; - ^$lambda(expressionSequence = [$from]); -} + let func = [ + pair($processingTemporal && $businessTemporal, getAll_Class_1__Date_1__Date_1__T_MANY_), + pair($processingTemporal || $businessTemporal, getAll_Class_1__Date_1__T_MANY_), + pair(true, getAll_Class_1__T_MANY_) + ]->filter(t | $t.first == true)->at(0).second; -function <> meta::external::dataquality::createLambdaBusinessTemporal(from: SimpleFunctionExpression[1]):LambdaFunction[1] -{ - let lambda = {businessDate: Date[1] | ''}; - ^$lambda(expressionSequence = [$from]); -} + let parameters = getTemporalParameters($processingTemporal, $businessTemporal); -function <> meta::external::dataquality::createLambdaBiTemporal(from: SimpleFunctionExpression[1]):LambdaFunction[1] -{ - let lambda = {businessDate: Date[1], processingDate: Date[1] | ''}; - ^$lambda(expressionSequence = [$from]); -} - - -function <> meta::external::dataquality::createGetAllBiTemporal(c: Class[1]):FunctionExpression[1] -{ - let getAllExpression = ^SimpleFunctionExpression + ^SimpleFunctionExpression ( - func = getAll_Class_1__Date_1__Date_1__T_MANY_, - functionName = getAll_Class_1__Date_1__Date_1__T_MANY_.name, + func = $func, + functionName = $func.name, importGroup = system::imports::coreImport, genericType = ^GenericType(rawType = $c), multiplicity = ZeroMany, - parametersValues = [ - ^InstanceValue( genericType = ^GenericType(rawType = Class, typeArguments = ^GenericType(rawType = $c)), + parametersValues = ^InstanceValue( genericType = ^GenericType(rawType = Class, typeArguments = ^GenericType(rawType = $c)), multiplicity = PureOne, values = $c - ), - ^VariableExpression(name='processingDate', genericType=^GenericType(rawType=Date), multiplicity=PureOne)->evaluateAndDeactivate(), - ^VariableExpression(name='businessDate', genericType=^GenericType(rawType=Date), multiplicity=PureOne)->evaluateAndDeactivate() - ] + )->concatenate($parameters) )->evaluateAndDeactivate(); - let classifierGenericType = ^GenericType(rawType = LambdaFunction, typeArguments = ^GenericType(rawType = ^FunctionType(returnMultiplicity = ZeroMany, returnType = ^GenericType(rawType = $c)))); - let lambda = {|[]}; - ^$lambda(classifierGenericType=$classifierGenericType, expressionSequence = $getAllExpression).expressionSequence->at(0)->cast(@FunctionExpression); } -function <> meta::external::dataquality::createGetAllBusinessTemporal(c: Class[1]):FunctionExpression[1] +function <> meta::external::dataquality::getTemporalParameters(processingTemporal:Boolean[1], businessTemporal:Boolean[1]):VariableExpression[*] { - let getAllExpression = ^SimpleFunctionExpression - ( - func = getAll_Class_1__Date_1__T_MANY_, - functionName = getAll_Class_1__Date_1__T_MANY_.name, - importGroup = system::imports::coreImport, - genericType = ^GenericType(rawType = $c), - multiplicity = ZeroMany, - parametersValues = [ - ^InstanceValue( genericType = ^GenericType(rawType = Class, typeArguments = ^GenericType(rawType = $c)), - multiplicity = PureOne, - values = $c - ), - ^VariableExpression(name='businessDate', genericType=^GenericType(rawType=Date), multiplicity=PureOne) - ] - )->evaluateAndDeactivate(); - let classifierGenericType = ^GenericType(rawType = LambdaFunction, typeArguments = ^GenericType(rawType = ^FunctionType(returnMultiplicity = ZeroMany, returnType = ^GenericType(rawType = $c)))); - let lambda = {|[]}; - ^$lambda(classifierGenericType=$classifierGenericType, expressionSequence = $getAllExpression).expressionSequence->at(0)->cast(@FunctionExpression); -} -function <> meta::external::dataquality::createGetAllProcessingTemporal(c: Class[1]):FunctionExpression[1] -{ - let getAllExpression = ^SimpleFunctionExpression - ( - func = getAll_Class_1__Date_1__T_MANY_, - functionName = getAll_Class_1__Date_1__T_MANY_.name, - importGroup = system::imports::coreImport, - genericType = ^GenericType(rawType = $c), - multiplicity = ZeroMany, - parametersValues = [ - ^InstanceValue( genericType = ^GenericType(rawType = Class, typeArguments = ^GenericType(rawType = $c)), - multiplicity = PureOne, - values = $c - ), - ^VariableExpression(name='processingDate', genericType=^GenericType(rawType=Date), multiplicity=PureOne) - ] - )->evaluateAndDeactivate(); - let classifierGenericType = ^GenericType(rawType = LambdaFunction, typeArguments = ^GenericType(rawType = ^FunctionType(returnMultiplicity = ZeroMany, returnType = ^GenericType(rawType = $c)))); - let lambda = {|[]}; - ^$lambda(classifierGenericType=$classifierGenericType, expressionSequence = $getAllExpression).expressionSequence->at(0)->cast(@FunctionExpression); + [ + pair($processingTemporal, ^VariableExpression(name='processingDate', genericType=^GenericType(rawType=Date), multiplicity=PureOne)->evaluateAndDeactivate()), + pair($businessTemporal, ^VariableExpression(name='businessDate', genericType=^GenericType(rawType=Date), multiplicity=PureOne)->evaluateAndDeactivate()) + ]->filter(f | $f.first).second->evaluateAndDeactivate(); } function meta::external::dataquality::generateFilterQuery(c:Class[1], f: FunctionExpression[1], filter:LambdaFunction<{T[1]->Boolean[1]}>[1]):FunctionExpression[1] { @@ -252,19 +252,36 @@ function meta::external::dataquality::generateFilterQuery(c:Class[1], f: F parametersValues = [ $f, ^InstanceValue ( - genericType = ^GenericType(rawType=LambdaFunction, typeArguments=^GenericType(rawType=^FunctionType(parameters=^VariableExpression(name='that', genericType=^GenericType(rawType = $c), multiplicity=PureOne), returnMultiplicity=PureOne, returnType=^GenericType(rawType=Boolean)))), + genericType = ^GenericType(rawType=LambdaFunction, typeArguments=^GenericType(rawType=^FunctionType(parameters=^VariableExpression(name='x', genericType=^GenericType(rawType = $c), multiplicity=PureOne), returnMultiplicity=PureOne, returnType=^GenericType(rawType=Boolean)))), multiplicity = PureOne, - values = ^$dummyLambda - ( - classifierGenericType = ^GenericType(rawType=LambdaFunction, typeArguments=^GenericType(rawType=^FunctionType(parameters=^VariableExpression(name='that', genericType=^GenericType(rawType = $c), multiplicity=PureOne), returnMultiplicity=PureOne, returnType=^GenericType(rawType=Boolean)))), - expressionSequence = $filter.expressionSequence->evaluateAndDeactivate() - ) + values = lambda(functionType('x', $c, PureOne, Boolean, ZeroMany), $filter.expressionSequence->evaluateAndDeactivate()->replaceVariableWithVariable('this', 'x')) ) ] )->evaluateAndDeactivate(); } +function meta::external::dataquality::lambda(functionType:FunctionType[1], expressionSequence:ValueSpecification[*]):LambdaFunction[1] +{ + let lambda = meta::pure::functions::meta::newLambdaFunction($functionType); + ^$lambda(expressionSequence = $expressionSequence->toOneMany()); +} + +function meta::external::dataquality::functionType(name:String[1], type:Type[1], multiplicity:Multiplicity[1], returnType:Type[1], returnMultiplicity:Multiplicity[1]):FunctionType[1] +{ + functionType($name, ^GenericType(rawType = $type), $multiplicity, ^GenericType(rawType = $returnType), $returnMultiplicity); +} + +function meta::external::dataquality::functionType(name:String[1], type:GenericType[1], multiplicity:Multiplicity[1], returnType:GenericType[1], returnMultiplicity:Multiplicity[1]):FunctionType[1] +{ + ^FunctionType(parameters = ^VariableExpression(genericType = $type, name = $name, multiplicity = $multiplicity), returnMultiplicity = $returnMultiplicity, returnType = $returnType); +} + +function meta::external::dataquality::functionType(parameters:VariableExpression[*], returnType:GenericType[1], returnMultiplicity:Multiplicity[1]):FunctionType[1] +{ + ^FunctionType(parameters = $parameters, returnMultiplicity = $returnMultiplicity, returnType = $returnType); +} + function meta::external::dataquality::generateConstraintsNegatedORQuery(c:Class[1], f: FunctionExpression[1], constraints: List[1]):FunctionExpression[1] { if ($constraints.values->isEmpty(), @@ -288,8 +305,7 @@ function meta::external::dataquality::generateORNegatedQuery(c:Class[1], f let final_expr = $constraints.values->drop(2)->fold({c3, curr_or_exp | let c3_negatedExprSequence = $c3.functionDefinition.expressionSequence->evaluateAndDeactivate()->toOne()->negatedFunctionExpression(); $c3_negatedExprSequence->orFunctionExpression($curr_or_exp);}, $c1_c2_or_expr); - - let dummyLambda = {|'ok'}; + ^SimpleFunctionExpression ( func = filter_T_MANY__Function_1__T_MANY_, @@ -301,23 +317,47 @@ function meta::external::dataquality::generateORNegatedQuery(c:Class[1], f ^InstanceValue ( genericType = $c1.functionDefinition.classifierGenericType->toOne(), multiplicity = PureOne, - values = ^$dummyLambda - ( - classifierGenericType = $c1.functionDefinition.classifierGenericType, - expressionSequence = $final_expr->evaluateAndDeactivate() - ) + values = lambda(functionType('x', $c, PureOne, Boolean, ZeroMany), $final_expr->evaluateAndDeactivate()->replaceVariableWithVariable('this', 'x')) ) ] )->evaluateAndDeactivate(); } +function meta::external::dataquality::replaceVariableWithVariable(v:ValueSpecification[1..*], from:String[1], to:String[1]):ValueSpecification[1..*] +{ + $v->map(a | $a->replaceVariableWithVariable($from, $to)) +} + +function meta::external::dataquality::replaceVariableWithVariable(v:ValueSpecification[1], from:String[1], to:String[1]):ValueSpecification[1] +{ + $v->match([ + v:VariableExpression[1] | if ($v.name == $from, | ^$v(name = $to), | $v), + s:SimpleFunctionExpression[1] | ^$s(parametersValues = $s.parametersValues->map(p | replaceVariableWithVariable($p, $from, $to))), + i:InstanceValue[1] | ^$i(values = $i.values->map(v | $v->replaceVariableWithVariable($from, $to))) + ]) +} + +function meta::external::dataquality::replaceVariableWithVariable(l:FunctionDefinition[1], from:String[1], to:String[1]):FunctionDefinition[1] +{ + ^$l(expressionSequence = $l.expressionSequence->replaceVariableWithVariable($from, $to)) +} + +function meta::external::dataquality::replaceVariableWithVariable(a:Any[1], from:String[1], to:String[1]):Any[1] +{ + $a->match([ + v:ValueSpecification[1] | $v->replaceVariableWithVariable($from, $to), + l:LambdaFunction[1] | $l->replaceVariableWithVariable($from, $to), + a:Any[1] | $a + ]) +} + function meta::external::dataquality::generateConstraintNegatedQuery(c:Class[1], f: FunctionExpression[1], constraint: Constraint[1]):FunctionExpression[1] { let constraintExprSequence = $constraint.functionDefinition.expressionSequence->evaluateAndDeactivate()->toOne(); let negatedExprSequence = $constraintExprSequence->negatedFunctionExpression(); - let dummyLambda = {|'ok'}; + ^SimpleFunctionExpression ( func = filter_T_MANY__Function_1__T_MANY_, @@ -329,11 +369,7 @@ function meta::external::dataquality::generateConstraintNegatedQuery(c:Class< ^InstanceValue ( genericType = $constraint.functionDefinition.classifierGenericType->toOne(), multiplicity = PureOne, - values = ^$dummyLambda - ( - classifierGenericType = $constraint.functionDefinition.classifierGenericType, - expressionSequence = $negatedExprSequence - ) + values = lambda(functionType('x', $c, PureOne, Boolean, ZeroMany), $negatedExprSequence->evaluateAndDeactivate()->replaceVariableWithVariable('this', 'x')) ) ] )->evaluateAndDeactivate(); @@ -432,8 +468,7 @@ function meta::external::dataquality::getEnrichedTreeForStructuralValidations(va function meta::external::dataquality::generateDQMetaDataForDQValidation(dataquality:meta::external::dataquality::DataQuality[1]): DataQualityRule[*] { let enrichedTree = ensureFunctionRequirementsForDataQuality($dataquality.validationTree, $dataquality.validationTree.constraints, $dataquality.validationTree.class, [], true)->cast(@RootGraphFetchTree); - let dqRules = $dataquality.validationTree->nodeToDqRule(true, '')->concatenate($enrichedTree->nodeToDqRule(false, '')); - $dqRules; + $dataquality.validationTree->nodeToDqRule(true, '')->concatenate($enrichedTree->nodeToDqRule(false, '')); } function meta::external::dataquality::nodeToDqRule(node:GraphFetchTree[1], processOnlyConstraints:Boolean[1], path:String[*]):DataQualityRule[*] @@ -466,5 +501,5 @@ function <> meta::external::dataquality::propertyNodeToDqRule(no function <> meta::external::dataquality::constraintToDqRule(constraint:Constraint[1], path:String[1]):DataQualityRule[1] { - ^DataQualityRule(constraintName=$constraint.name->toOne(), constraintGrammar=$constraint.functionDefinition->meta::pure::metamodel::serialization::grammar::printFunctionDefinitionExpressions('')->toOne(), constraintType='Alloy_Constraint_Validation', propertyPath=$path); + ^DataQualityRule(constraintName=$constraint.name->toOne(), constraintGrammar=$constraint.functionDefinition->replaceVariableWithVariable('this', 'x')->meta::pure::metamodel::serialization::grammar::printFunctionDefinitionExpressions('')->toOne(), constraintType='Alloy_Constraint_Validation', propertyPath=$path); } \ No newline at end of file diff --git a/legend-engine-xts-dataquality/pom.xml b/legend-engine-xts-dataquality/pom.xml index 13f9cb09514..635bc5d9d49 100644 --- a/legend-engine-xts-dataquality/pom.xml +++ b/legend-engine-xts-dataquality/pom.xml @@ -3,7 +3,7 @@ legend-engine org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-compiler/pom.xml b/legend-engine-xts-diagram/legend-engine-xt-diagram-compiler/pom.xml index dc29b311b72..80aa7450939 100644 --- a/legend-engine-xts-diagram/legend-engine-xt-diagram-compiler/pom.xml +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-compiler/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-diagram org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-grammar/pom.xml b/legend-engine-xts-diagram/legend-engine-xt-diagram-grammar/pom.xml index 9c2b510323f..d287e1f5a52 100644 --- a/legend-engine-xts-diagram/legend-engine-xt-diagram-grammar/pom.xml +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-grammar/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-diagram - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-http-api/pom.xml b/legend-engine-xts-diagram/legend-engine-xt-diagram-http-api/pom.xml index d24006966e7..1c61cf30f75 100644 --- a/legend-engine-xts-diagram/legend-engine-xt-diagram-http-api/pom.xml +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-diagram - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-protocol/pom.xml b/legend-engine-xts-diagram/legend-engine-xt-diagram-protocol/pom.xml index b71379d2635..9380fb12269 100644 --- a/legend-engine-xts-diagram/legend-engine-xt-diagram-protocol/pom.xml +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-diagram - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-pure-metamodel/pom.xml b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure-metamodel/pom.xml index 3d9f7e1b618..812b7fb3c18 100644 --- a/legend-engine-xts-diagram/legend-engine-xt-diagram-pure-metamodel/pom.xml +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure-metamodel/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-diagram - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -84,11 +84,6 @@ - - org.finos.legend.pure - legend-pure-m2-dsl-mapping-grammar - ${legend.pure.version} - org.finos.legend.pure legend-pure-m2-dsl-diagram-grammar @@ -109,6 +104,11 @@ org.finos.legend.pure legend-pure-m3-core + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-pure + runtime + org.finos.legend.pure legend-pure-runtime-java-engine-compiled @@ -126,5 +126,23 @@ org.eclipse.collections eclipse-collections-api + + + + junit + junit + + + org.finos.legend.pure + legend-pure-m3-core + test-jar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + + diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-pure-metamodel/src/test/java/org/finos/legend/pure/code/core/TestCoreDiagramMetamodelCompiledStateIntegrity.java b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure-metamodel/src/test/java/org/finos/legend/pure/code/core/TestCoreDiagramMetamodelCompiledStateIntegrity.java new file mode 100644 index 00000000000..7c8330f574c --- /dev/null +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure-metamodel/src/test/java/org/finos/legend/pure/code/core/TestCoreDiagramMetamodelCompiledStateIntegrity.java @@ -0,0 +1,27 @@ +// Copyright 2024 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. + +package org.finos.legend.pure.code.core; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; + +public class TestCoreDiagramMetamodelCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_diagram_metamodel"); + } +} diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-pure/pom.xml b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure/pom.xml index c9e39911eb3..5d5eca92c01 100644 --- a/legend-engine-xts-diagram/legend-engine-xt-diagram-pure/pom.xml +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-diagram - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -158,5 +158,23 @@ org.eclipse.collections eclipse-collections-api + + + + junit + junit + + + org.finos.legend.pure + legend-pure-m3-core + test-jar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + + diff --git a/legend-engine-xts-diagram/legend-engine-xt-diagram-pure/src/test/java/org/finos/legend/pure/code/core/TestCoreDiagramCompiledStateIntegrity.java b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure/src/test/java/org/finos/legend/pure/code/core/TestCoreDiagramCompiledStateIntegrity.java new file mode 100644 index 00000000000..b8f11374afa --- /dev/null +++ b/legend-engine-xts-diagram/legend-engine-xt-diagram-pure/src/test/java/org/finos/legend/pure/code/core/TestCoreDiagramCompiledStateIntegrity.java @@ -0,0 +1,27 @@ +// Copyright 2024 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. + +package org.finos.legend.pure.code.core; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; + +public class TestCoreDiagramCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_diagram"); + } +} diff --git a/legend-engine-xts-diagram/pom.xml b/legend-engine-xts-diagram/pom.xml index dceee3eaab4..9af816b71af 100644 --- a/legend-engine-xts-diagram/pom.xml +++ b/legend-engine-xts-diagram/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-executionPlan/pom.xml b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-executionPlan/pom.xml index 3690d85c3a0..bfbc322de0d 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-executionPlan/pom.xml +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-executionPlan/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-elasticsearch - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-grammar/pom.xml b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-grammar/pom.xml index b2e774fb346..f1d7a8b9ec2 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-grammar/pom.xml +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-elasticsearch - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-protocol/pom.xml b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-protocol/pom.xml index 9363f92f66d..e59f39128c7 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-protocol/pom.xml +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-elasticsearch - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/pom.xml b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/pom.xml index d37f764b504..1f5335a13bc 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/pom.xml +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-elasticsearch - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/pom.xml b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/pom.xml index af2f1c165dc..ed05c57b3f9 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/pom.xml +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-elasticsearch - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchRequestCommand.java b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchRequestCommand.java index d7d96639b5f..b8d27757a54 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchRequestCommand.java +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchRequestCommand.java @@ -18,6 +18,7 @@ import java.util.Stack; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; import org.finos.legend.pure.m3.navigation.Instance; @@ -46,7 +47,7 @@ public ElasticsearchRequestCommand(FunctionExecutionInterpreted functionExecutio } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance imageTagCoreInstance = params.get(0); String imageTag = Instance.getValueForMetaPropertyToOneResolved(imageTagCoreInstance, M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStartCommand.java b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStartCommand.java index a1c47338906..d5b61033ec9 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStartCommand.java +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStartCommand.java @@ -18,6 +18,7 @@ import java.util.Stack; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.pure.generated.Root_meta_pure_functions_io_http_URL; import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl; import org.finos.legend.pure.m3.compiler.Context; @@ -50,7 +51,7 @@ public ElasticsearchStartCommand(FunctionExecutionInterpreted functionExecution, } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance imageTagCoreInstance = params.get(0); String imageTag = Instance.getValueForMetaPropertyToOneResolved(imageTagCoreInstance, M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStopCommand.java b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStopCommand.java index a014d59894a..ec19f9f3743 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStopCommand.java +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/elasticsearch/test/interpreted/ElasticsearchStopCommand.java @@ -18,6 +18,7 @@ import java.util.Stack; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -47,7 +48,7 @@ public ElasticsearchStopCommand(FunctionExecutionInterpreted functionExecution, } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance imageTagCoreInstance = params.get(0); String imageTag = Instance.getValueForMetaPropertyToOneResolved(imageTagCoreInstance, M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-protocol-utils/pom.xml b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-protocol-utils/pom.xml index f6c1afa2161..837c8ccff7d 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-protocol-utils/pom.xml +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-protocol-utils/pom.xml @@ -4,7 +4,7 @@ org.finos.legend.engine legend-engine-xts-elasticsearch - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-elasticsearch-protocol-utils diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-pure-specification-metamodel/pom.xml b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-pure-specification-metamodel/pom.xml index 3f4b3f9a421..5c7b30de423 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-pure-specification-metamodel/pom.xml +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-pure-specification-metamodel/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-elasticsearch - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-elasticsearch/pom.xml b/legend-engine-xts-elasticsearch/pom.xml index 559aabafb3d..bc223c93f21 100644 --- a/legend-engine-xts-elasticsearch/pom.xml +++ b/legend-engine-xts-elasticsearch/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-driver-bloomberg/pom.xml b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-driver-bloomberg/pom.xml index 086f39d7965..9a4239cc8f3 100644 --- a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-driver-bloomberg/pom.xml +++ b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-driver-bloomberg/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-flatdata org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-pure/pom.xml b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-pure/pom.xml index db523cf9b44..89034c82c90 100644 --- a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-pure/pom.xml +++ b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-flatdata - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-test/pom.xml b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-test/pom.xml index b343097cee7..c948f02747b 100644 --- a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-test/pom.xml +++ b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-javaPlatformBinding-test/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-flatdata - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-model/pom.xml b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-model/pom.xml index ad7e73af62b..b9c0248f23c 100644 --- a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-model/pom.xml +++ b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-model/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-flatdata - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-pure/pom.xml b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-pure/pom.xml index a453aa73a80..3847905c380 100644 --- a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-pure/pom.xml +++ b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-flatdata - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-runtime/pom.xml b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-runtime/pom.xml index 336f7bc57cc..8af5cdd8d75 100644 --- a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-runtime/pom.xml +++ b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-runtime/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-flatdata - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-shared/pom.xml b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-shared/pom.xml index 8be833cd666..a5318f178ce 100644 --- a/legend-engine-xts-flatdata/legend-engine-xt-flatdata-shared/pom.xml +++ b/legend-engine-xts-flatdata/legend-engine-xt-flatdata-shared/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-flatdata - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-flatdata/pom.xml b/legend-engine-xts-flatdata/pom.xml index adc970b3edb..ff94c378300 100644 --- a/legend-engine-xts-flatdata/pom.xml +++ b/legend-engine-xts-flatdata/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/pom.xml b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/pom.xml new file mode 100644 index 00000000000..dd4a4a80765 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/pom.xml @@ -0,0 +1,66 @@ + + + + + 4.0.0 + + org.finos.legend.engine + legend-engine-xts-functionActivator + 4.65.3-SNAPSHOT + + + legend-engine-xt-functionActivator-compiler + jar + Legend Engine - XT - Function Activator - Compiler + + + + + + org.finos.legend.engine + legend-engine-language-pure-compiler + + + org.finos.legend.engine + legend-engine-shared-core + + + org.finos.legend.engine + legend-engine-protocol-pure + + + org.finos.legend.engine + legend-engine-xt-functionActivator-pure + + + org.finos.legend.engine + legend-engine-xt-functionActivator-protocol + + + + + + org.eclipse.collections + eclipse-collections + + + org.eclipse.collections + eclipse-collections-api + + + + \ No newline at end of file diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/src/main/java/org/finos/legend/engine/language/functionActivator/compiler/toPureGraph/postDeployment/HelperPostDeploymentCompilerBuilder.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/src/main/java/org/finos/legend/engine/language/functionActivator/compiler/toPureGraph/postDeployment/HelperPostDeploymentCompilerBuilder.java new file mode 100644 index 00000000000..e2898f012ea --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/src/main/java/org/finos/legend/engine/language/functionActivator/compiler/toPureGraph/postDeployment/HelperPostDeploymentCompilerBuilder.java @@ -0,0 +1,35 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.language.functionActivator.compiler.toPureGraph.postDeployment; + +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext; +import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; +import org.finos.legend.pure.generated.Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction; + +import java.util.List; + +public class HelperPostDeploymentCompilerBuilder +{ + public static MutableList resolveDeploymentAction(List actions, CompileContext context) + { + List extensions = IPostDeploymentCompilerExtension.getExtensions(); + return ListIterate.collect(actions, action -> IPostDeploymentCompilerExtension.process( + action, + ListIterate.flatCollect(extensions, IPostDeploymentCompilerExtension::getExtraPostDeploymentActionProcessors), + context)); + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/src/main/java/org/finos/legend/engine/language/functionActivator/compiler/toPureGraph/postDeployment/IPostDeploymentCompilerExtension.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/src/main/java/org/finos/legend/engine/language/functionActivator/compiler/toPureGraph/postDeployment/IPostDeploymentCompilerExtension.java new file mode 100644 index 00000000000..b909f901fcd --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/src/main/java/org/finos/legend/engine/language/functionActivator/compiler/toPureGraph/postDeployment/IPostDeploymentCompilerExtension.java @@ -0,0 +1,57 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.language.functionActivator.compiler.toPureGraph.postDeployment; + +import org.eclipse.collections.api.block.function.Function2; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.impl.list.mutable.FastList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; +import org.finos.legend.pure.generated.Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction; + +import java.util.List; +import java.util.Objects; +import java.util.ServiceLoader; + +public interface IPostDeploymentCompilerExtension extends CompilerExtension +{ + static List getExtensions() + { + return Lists.mutable.withAll(ServiceLoader.load(IPostDeploymentCompilerExtension.class)); + } + + static Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction process(PostDeploymentAction postDeploymentAction, List> processors, CompileContext context) + { + return process(postDeploymentAction, processors, context, "Post Deployment Compiler Extension"); + } + + static U process(T item, List> processors, CompileContext context, String type) + { + return ListIterate + .collect(processors, processor -> processor.value(item, context)) + .select(Objects::nonNull) + .getFirstOptional() + .orElseThrow(() -> new EngineException("Unsupported " + type + " type '" + item.getClass() + "'", EngineErrorType.COMPILATION)); + } + + default List> getExtraPostDeploymentActionProcessors() + { + return FastList.newList(); + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/pom.xml b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/pom.xml index fcff25b4e49..d5004c7cb8e 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/pom.xml +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-functionActivator - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -34,9 +34,23 @@ org.finos.legend.engine legend-engine-identity-core - + + org.finos.legend.engine + legend-engine-xt-functionActivator-protocol + + + org.finos.legend.engine + legend-engine-xt-functionActivator-generation + + + + org.eclipse.collections + eclipse-collections-api + + + junit @@ -48,11 +62,6 @@ log4j test - - org.finos.legend.engine - legend-engine-xt-functionActivator-protocol - - diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/src/main/java/org/finos/legend/engine/functionActivator/deployment/DeploymentManager.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/src/main/java/org/finos/legend/engine/functionActivator/deployment/DeploymentManager.java index cde36ea9980..0a02cc0cac0 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/src/main/java/org/finos/legend/engine/functionActivator/deployment/DeploymentManager.java +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-deployment/src/main/java/org/finos/legend/engine/functionActivator/deployment/DeploymentManager.java @@ -14,9 +14,12 @@ package org.finos.legend.engine.functionActivator.deployment; +import org.eclipse.collections.api.factory.Lists; +import org.finos.legend.engine.functionActivator.postDeployment.PostDeploymentActionLoader; import org.finos.legend.engine.protocol.functionActivator.deployment.DeploymentResult; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorDeploymentConfiguration; +import org.finos.legend.engine.protocol.functionActivator.deployment.PostDeploymentActionResult; import org.finos.legend.engine.shared.core.identity.Identity; import java.util.List; @@ -31,4 +34,14 @@ public interface DeploymentManager availableRuntimeConfigurations); public boolean canDeploy(FunctionActivatorArtifact activatorArtifact); + + public default List deployActions(Identity identity, U artifact) + { + List actionResults = Lists.mutable.empty(); + PostDeploymentActionLoader.extensions().forEach((ex) -> + { + actionResults.addAll(ex.processAction(identity, artifact)); + }); + return actionResults; + } } diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/pom.xml b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/pom.xml index 35784389891..2f7598422b6 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/pom.xml +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-functionActivator - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -52,11 +52,14 @@ org.finos.legend.engine legend-engine-language-pure-compiler - org.finos.legend.engine legend-engine-xt-functionActivator-pure + + org.finos.legend.engine + legend-engine-identity-core + diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/src/main/java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentActionLoader.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/src/main/java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentActionLoader.java new file mode 100644 index 00000000000..c697a64fcdf --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/src/main/java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentActionLoader.java @@ -0,0 +1,65 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.functionActivator.postDeployment; + +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.factory.Lists; +import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; +import org.finos.legend.pure.generated.Root_meta_external_function_activator_FunctionActivator; + +import java.util.List; +import java.util.ServiceLoader; +import java.util.concurrent.atomic.AtomicReference; + +public class PostDeploymentActionLoader +{ + private static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger(PostDeploymentContract.class); + private static final AtomicReference> INSTANCE = new AtomicReference<>(); + + public static MutableList extensions() + { + return INSTANCE.updateAndGet(existing -> + { + if (existing == null) + { + MutableList extensions = Lists.mutable.empty(); + for (PostDeploymentContract extension : ServiceLoader.load(PostDeploymentContract.class)) + { + try + { + extensions.add(extension); + } + catch (Throwable throwable) + { + LOGGER.error("Failed to load execution extension '" + extension.getClass().getSimpleName() + "'"); + } + } + return extensions; + } + return existing; + }); + } + + public static List generateActions(Root_meta_external_function_activator_FunctionActivator activator) + { + List actionsContent = Lists.mutable.empty(); + extensions().forEach(e -> + { + actionsContent.addAll(e.generate(activator._actions())); + }); + + return actionsContent; + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/src/main/java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentContract.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/src/main/java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentContract.java new file mode 100644 index 00000000000..4d2fb95d012 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-generation/src/main/java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentContract.java @@ -0,0 +1,32 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.functionActivator.postDeployment; + +import org.eclipse.collections.api.RichIterable; +import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; +import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorDeploymentConfiguration; +import org.finos.legend.engine.protocol.functionActivator.deployment.PostDeploymentActionResult; +import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; +import org.finos.legend.engine.shared.core.identity.Identity; +import org.finos.legend.pure.generated.Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction; + +import java.util.List; + +public interface PostDeploymentContract +{ + List generate(RichIterable actions); + + List processAction(Identity identity, FunctionActivatorArtifact artifact); +} \ No newline at end of file diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/pom.xml b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/pom.xml new file mode 100644 index 00000000000..1dde2daba00 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/pom.xml @@ -0,0 +1,147 @@ + + + + + org.finos.legend.engine + legend-engine-xts-functionActivator + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-xt-functionActivator-grammar + jar + Legend Engine - XT - Function Activator - Grammar + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-antlr-core-grammar + initialize + + unpack + + + + + org.finos.legend.engine + legend-engine-language-pure-grammar + jar + false + ${project.build.directory} + antlr/*.g4 + + + + + + + + org.antlr + antlr4-maven-plugin + + + + antlr4 + + + true + true + true + target/antlr + target/generated-sources + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + + + + org.finos.legend.engine + legend-engine-language-pure-grammar + + + org.finos.legend.engine + legend-engine-shared-core + + + org.finos.legend.engine + legend-engine-protocol-pure + + + org.finos.legend.engine + legend-engine-protocol + + + org.finos.legend.engine + legend-engine-xt-relationalStore-grammar + + + org.finos.legend.engine + legend-engine-xt-functionActivator-protocol + + + + + + org.eclipse.collections + eclipse-collections + + + org.eclipse.collections + eclipse-collections-api + + + + + + junit + junit + test + + + org.finos.legend.engine + legend-engine-shared-core + test-jar + test + + + org.finos.legend.engine + legend-engine-language-pure-grammar + test-jar + test + + + + \ No newline at end of file diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/from/IPostDeploymentActionGrammarParserExtension.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/from/IPostDeploymentActionGrammarParserExtension.java new file mode 100644 index 00000000000..4f16859cd71 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/from/IPostDeploymentActionGrammarParserExtension.java @@ -0,0 +1,50 @@ +// Copyright 2021 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. + +package org.finos.legend.engine.language.functionActivator.grammar.postDeployment.from; + +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.grammar.from.extension.PureGrammarParserExtension; +import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.ServiceLoader; +import java.util.function.Function; + +public interface IPostDeploymentActionGrammarParserExtension extends PureGrammarParserExtension +{ + static List getExtensions() + { + return Lists.mutable.withAll(ServiceLoader.load(IPostDeploymentActionGrammarParserExtension.class)); + } + + default List> getExtraPostDeploymentActionParsers() + { + return Collections.emptyList(); + } + + static PostDeploymentAction process(PostDeploymentActionSourceCode code, List> processors) + { + return ListIterate + .collect(processors, processor -> processor.apply(code)) + .select(Objects::nonNull) + .getFirstOptional() + .orElseThrow(() -> new EngineException("Unsupported " + " type '" + code.getType() + "'", code.getSourceInformation(), EngineErrorType.PARSER)); + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/from/PostDeploymentActionSourceCode.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/from/PostDeploymentActionSourceCode.java new file mode 100644 index 00000000000..710609c1853 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/from/PostDeploymentActionSourceCode.java @@ -0,0 +1,27 @@ +// Copyright 2021 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. + +package org.finos.legend.engine.language.functionActivator.grammar.postDeployment.from; + +import org.finos.legend.engine.language.pure.grammar.from.ParseTreeWalkerSourceInformation; +import org.finos.legend.engine.language.pure.grammar.from.SpecificationSourceCode; +import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; + +public class PostDeploymentActionSourceCode extends SpecificationSourceCode +{ + public PostDeploymentActionSourceCode(String code, String type, SourceInformation sourceInformation, ParseTreeWalkerSourceInformation walkerSourceInformation) + { + super(code, type, sourceInformation, walkerSourceInformation); + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/to/IPostDeploymentActionGrammarComposerExtension.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/to/IPostDeploymentActionGrammarComposerExtension.java new file mode 100644 index 00000000000..4dca86bd64f --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/to/IPostDeploymentActionGrammarComposerExtension.java @@ -0,0 +1,55 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.language.functionActivator.grammar.postDeployment.to; + +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.impl.list.mutable.FastList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension; +import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; + +import java.util.List; +import java.util.Objects; +import java.util.ServiceLoader; + +public interface IPostDeploymentActionGrammarComposerExtension extends PureGrammarComposerExtension +{ + static List getExtensions() + { + return Lists.mutable.withAll(ServiceLoader.load(IPostDeploymentActionGrammarComposerExtension.class)); + } + + static String process(PostDeploymentAction postDeploymentAction, List> processors) + { + return process(postDeploymentAction, processors, "Post Deployment Action"); + } + + static String process(T item, List> processors, String type) + { + return ListIterate + .collect(processors, processor -> processor.valueOf(item)) + .select(Objects::nonNull) + .getFirstOptional() + .orElseThrow(() -> new EngineException("Unsupported " + type + " type '" + item.getClass() + "'", EngineErrorType.PARSER)); + } + + default List> getExtraPostDeploymentActionComposer() + { + return FastList.newList(); + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/to/PostDeploymentActionGrammarComposer.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/to/PostDeploymentActionGrammarComposer.java new file mode 100644 index 00000000000..10c00a917d7 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/java/org/finos/legend/engine/language/functionActivator/grammar/postDeployment/to/PostDeploymentActionGrammarComposer.java @@ -0,0 +1,37 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.language.functionActivator.grammar.postDeployment.to; + +import org.eclipse.collections.impl.list.mutable.FastList; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension; +import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; +import java.util.List; +import static org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.getTabString; + +public class PostDeploymentActionGrammarComposer implements PureGrammarComposerExtension +{ + public static String renderActions(List actions) + { + List postDeploymentActionStrings = FastList.newList(); + List extensions = IPostDeploymentActionGrammarComposerExtension.getExtensions(); + + postDeploymentActionStrings.addAll(ListIterate.collect(actions, action -> IPostDeploymentActionGrammarComposerExtension.process( + action, + ListIterate.flatCollect(extensions, IPostDeploymentActionGrammarComposerExtension::getExtraPostDeploymentActionComposer) + ))); + return " actions: [\n" + getTabString() + String.join(",\n", postDeploymentActionStrings) + "\n" + getTabString() + "];"; + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/resources/META-INF/services/org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/resources/META-INF/services/org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension new file mode 100644 index 00000000000..9213f861628 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-grammar/src/main/resources/META-INF/services/org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension @@ -0,0 +1 @@ +org.finos.legend.engine.language.functionActivator.grammar.postDeployment.to.PostDeploymentActionGrammarComposer \ No newline at end of file diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-http-api/pom.xml b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-http-api/pom.xml index 0729ca570ff..e1afda3cc3d 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-http-api/pom.xml +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-functionActivator - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/pom.xml b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/pom.xml index 0852d8b6856..38d12825aeb 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/pom.xml +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-functionActivator - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -28,14 +28,27 @@ Legend Engine - XT - Function Activator - Protocol + org.finos.legend.engine legend-engine-protocol-pure + + + + + org.eclipse.collections + eclipse-collections-api + + + + com.fasterxml.jackson.core jackson-annotations + + junit diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/DeploymentResult.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/DeploymentResult.java index 315b0d3bf75..fa391ceb58b 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/DeploymentResult.java +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/DeploymentResult.java @@ -14,11 +14,14 @@ package org.finos.legend.engine.protocol.functionActivator.deployment; +import java.util.List; + public class DeploymentResult { public String activatorIdentifier; public boolean successful; public String deploymentLocation; + public List actionResults; @Override public String toString() diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java index 8080dbb41f3..946773adc9a 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/FunctionActivatorArtifact.java @@ -16,7 +16,10 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.eclipse.collections.api.factory.Lists; +import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; +import java.util.List; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type") @JsonIgnoreProperties(ignoreUnknown = true) @@ -24,6 +27,7 @@ public class FunctionActivatorArtifact { public FunctionActivatorDeploymentContent content; public FunctionActivatorDeploymentConfiguration deploymentConfiguration; + public List actions = Lists.mutable.empty(); public String version; diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/PostDeploymentActionResult.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/PostDeploymentActionResult.java new file mode 100644 index 00000000000..84959c0e167 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/deployment/PostDeploymentActionResult.java @@ -0,0 +1,34 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.protocol.functionActivator.deployment; + +public class PostDeploymentActionResult +{ + public String actionType; + public boolean success; + public String detail; + + public PostDeploymentActionResult() + { + + } + + public PostDeploymentActionResult(String actionType, boolean success, String detail) + { + this.actionType = actionType; + this.success = success; + this.detail = detail; + } +} diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/FunctionActivator.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/FunctionActivator.java index 9b1e50caef6..4ee7452380a 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/FunctionActivator.java +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/FunctionActivator.java @@ -32,4 +32,5 @@ public abstract class FunctionActivator extends PackageableElement public PackageableElementPointer function; public DeploymentConfiguration activationConfiguration; public Ownership ownership; + public List actions = Collections.emptyList(); } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuerySourceREPLExecutedQuery.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/PostDeploymentAction.java similarity index 72% rename from legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuerySourceREPLExecutedQuery.java rename to legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/PostDeploymentAction.java index b8c36b1cdf1..ef1464440b2 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuerySourceREPLExecutedQuery.java +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/PostDeploymentAction.java @@ -1,4 +1,4 @@ -// Copyright 2024 Goldman Sachs +// Copyright 2023 Goldman Sachs // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -package org.finos.legend.engine.repl.dataCube.server.model; +package org.finos.legend.engine.protocol.functionActivator.metamodel; -public class DataCubeQuerySourceREPLExecutedQuery extends DataCubeQuerySource +public class PostDeploymentAction { -} + public PostDeploymentProperties properties; + public boolean automated; +} \ No newline at end of file diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/PostDeploymentProperties.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/PostDeploymentProperties.java new file mode 100644 index 00000000000..b71d4e02388 --- /dev/null +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/metamodel/PostDeploymentProperties.java @@ -0,0 +1,22 @@ +// Copyright 2023 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. + +package org.finos.legend.engine.protocol.functionActivator.metamodel; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type") +public class PostDeploymentProperties +{ +} \ No newline at end of file diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuerySource.java b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/postDeployment/ActionContent.java similarity index 59% rename from legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuerySource.java rename to legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/postDeployment/ActionContent.java index 710e9f6fac7..5a498eb17da 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQuerySource.java +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-protocol/src/main/java/org/finos/legend/engine/protocol/functionActivator/postDeployment/ActionContent.java @@ -1,4 +1,4 @@ -// Copyright 2024 Goldman Sachs +// Copyright 2023 Goldman Sachs // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,21 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package org.finos.legend.engine.repl.dataCube.server.model; +package org.finos.legend.engine.protocol.functionActivator.postDeployment; -import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import java.util.List; - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = DataCubeQuerySourceREPLExecutedQuery.class, name = "REPLExecutedQuery") -}) -public abstract class DataCubeQuerySource +public class ActionContent { - public String query; - public String mapping; - public String runtime; - public List columns; } diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/pom.xml b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/pom.xml index bf17837e3d4..8dcbdfb15ff 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/pom.xml +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-functionActivator - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/src/main/resources/core_function_activator/metamodel.pure b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/src/main/resources/core_function_activator/metamodel.pure index 2d555cc14ee..0fcac18816a 100644 --- a/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/src/main/resources/core_function_activator/metamodel.pure +++ b/legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-pure/src/main/resources/core_function_activator/metamodel.pure @@ -1,10 +1,12 @@ import meta::external::function::activator::*; +import meta::external::function::activator::postDeploymentAction::*; Class meta::external::function::activator::FunctionActivator extends PackageableElement { {doc.doc = 'The function that needs to be activated.'} function : PackageableFunction[1]; {doc.doc = 'The activation configuration.'} activationConfiguration : DeploymentConfiguration[0..1]; {doc.doc = 'The ownership criteria.'} ownership : Ownership[1]; + {doc.doc = 'Optional action that can be executed after deployment'} actions : meta::external::function::activator::postDeploymentAction::PostDeploymentAction[*]; } @@ -33,6 +35,17 @@ Class meta::external::function::activator::DeploymentOwnership extends meta::ext id: String[1]; } +Class meta::external::function::activator::postDeploymentAction::PostDeploymentAction +{ + automated: Boolean[0..1]; + properties: PostDeploymentActionProperties[1]; +} + +Class meta::external::function::activator::postDeploymentAction::PostDeploymentActionProperties +{ + +} + // This section needs to be code generated from the section above Class meta::protocols::pure::vX_X_X::metamodel::function::activator::FunctionActivator extends meta::protocols::pure::vX_X_X::metamodel::PackageableElement, meta::protocols::pure::vX_X_X::metamodel::domain::AnnotatedElement { diff --git a/legend-engine-xts-functionActivator/pom.xml b/legend-engine-xts-functionActivator/pom.xml index ca1c17b3bc0..e03bf899900 100644 --- a/legend-engine-xts-functionActivator/pom.xml +++ b/legend-engine-xts-functionActivator/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -34,6 +34,8 @@ legend-engine-xt-functionActivator-protocol legend-engine-xt-functionActivator-pure legend-engine-xt-functionActivator-generation + legend-engine-xt-functionActivator-compiler + legend-engine-xt-functionActivator-grammar \ No newline at end of file diff --git a/legend-engine-xts-generation/legend-engine-external-shared/pom.xml b/legend-engine-xts-generation/legend-engine-external-shared/pom.xml index 2e98d3cf774..ac53110c79f 100644 --- a/legend-engine-xts-generation/legend-engine-external-shared/pom.xml +++ b/legend-engine-xts-generation/legend-engine-external-shared/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation-pure/pom.xml b/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation-pure/pom.xml index e33468de49e..11698ff1865 100644 --- a/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation-pure/pom.xml +++ b/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation/pom.xml b/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation/pom.xml index d67c7b1740f..12f12eaefb4 100644 --- a/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation/pom.xml +++ b/legend-engine-xts-generation/legend-engine-language-pure-dsl-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-language-pure-dsl-generation diff --git a/legend-engine-xts-generation/legend-engine-xt-artifact-generation-http-api/pom.xml b/legend-engine-xts-generation/legend-engine-xt-artifact-generation-http-api/pom.xml index bec1572a587..2ff45cf420e 100644 --- a/legend-engine-xts-generation/legend-engine-xt-artifact-generation-http-api/pom.xml +++ b/legend-engine-xts-generation/legend-engine-xt-artifact-generation-http-api/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-generation org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-generation/pom.xml b/legend-engine-xts-generation/pom.xml index d8e4b349cdc..d8ba9935dad 100644 --- a/legend-engine-xts-generation/pom.xml +++ b/legend-engine-xts-generation/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-compiler/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-compiler/pom.xml index 511c4e3635c..e51ea1a3fbf 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-compiler/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-compiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -73,7 +73,7 @@ org.finos.legend.engine legend-engine-protocol-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT org.finos.legend.pure diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-generation-http-api/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-generation-http-api/pom.xml index 1dcbe005fab..02b91352435 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-generation-http-api/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-generation-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-graphQL-generation-http-api diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar-integration/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar-integration/pom.xml index b9a4832aa31..5a6742b24f0 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar-integration/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar-integration/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar/pom.xml index 1b89c698a8c..836aca2e418 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-http-api/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-http-api/pom.xml index cd9bac4dee9..d85dc6a8750 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-http-api/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-protocol/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-protocol/pom.xml index f6c33827fac..17cf4d13abe 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-protocol/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure-metamodel/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure-metamodel/pom.xml index 448fe25ce1d..2f994a414a9 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure-metamodel/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure-metamodel/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/pom.xml index 8c419c1b1a4..3c836759f35 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/fromPure_sdl.pure b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/fromPure_sdl.pure index ff20e9fb6e8..d938f590a0a 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/fromPure_sdl.pure +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/fromPure_sdl.pure @@ -98,7 +98,7 @@ function meta::external::query::graphQL::binding::fromPure::sdl::transformPureTo ->distinct() ->filter(t | $t->instanceOf(Class)); - let extendedClasses = $allTypes->map(t | $t->validGeneralizations()); + let extendedClasses = $allTypes->map(t | $t->validGeneralizations())->removeDuplicates(); // Build types let graphQLTypes = $allTypes->map(c | @@ -301,11 +301,12 @@ function <> meta::external::query::graphQL::binding::fromPure::s let nonBuiltInScalars = $props->buildNonBuiltInGraphQLScalars($pureTypeToGraphQLScalarOverride); let isQueryClass = $c->hasGraphQLStereotype('Query'); let temporalStereotypes = $c->getTemporalStereotypes(); + let extended = if($isExtended, | [$c.name], | []); $nonBuiltInScalars ->concatenate( ^ObjectTypeDefinition( name = $c.name->toOne(), - implements = if($isExtended, | $c.name, | $c->validGeneralizations()->map(g | $g.name))->map(n | $n->toInterfaceTypeName()), + implements = $extended->concatenate($c->hierarchicalAllGeneralizations()->map(g | $g.name))->map(n | $n->toInterfaceTypeName()), directives = $temporalStereotypes->map(s | temporalityToDirectives()->get($s)->toOne())->map(def | ^Directive(name = $def.name))->concatenate(buildHierarchyDirective($c, false)), fields = $props ->map(p | @@ -351,7 +352,7 @@ function <> meta::external::query::graphQL::binding::fromPure::s let temporalStereotypes = $c->getTemporalStereotypes(); ^InterfaceTypeDefinition( name = $c.name->toOne()->toInterfaceTypeName(), - implements = $c->validGeneralizations()->map(g | $g.name)->map(n | $n->toInterfaceTypeName()), + implements = $c->hierarchicalAllGeneralizations()->map(g | $g.name)->map(n | $n->toInterfaceTypeName()), directives = $temporalStereotypes->map(s | temporalityToDirectives()->get($s)->toOne())->map(def | ^Directive(name = $def.name))->concatenate(buildHierarchyDirective($c, false)), fields = $props ->map(p | diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/tests/simpleTest.pure b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/tests/simpleTest.pure index 8cd0f84a6df..edc27b128bb 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/tests/simpleTest.pure +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/fromPure/sdl/tests/simpleTest.pure @@ -21,6 +21,18 @@ Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::Pers age : Integer[1]; } +Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::NonEmployee extends meta::external::query::graphQL::binding::fromPure::sdl::tests::model::Person +{ +} + +Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::SelfEmployed extends meta::external::query::graphQL::binding::fromPure::sdl::tests::model::NonEmployee +{ +} + +Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::Contractor extends meta::external::query::graphQL::binding::fromPure::sdl::tests::model::SelfEmployed +{ +} + Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::Employee extends meta::external::query::graphQL::binding::fromPure::sdl::tests::model::Person { title: String[1]; @@ -32,6 +44,11 @@ Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::GSEm division: String[1]; } +Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::NonGSEmployee extends meta::external::query::graphQL::binding::fromPure::sdl::tests::model::Employee +{ + company: String[1]; +} + Class meta::external::query::graphQL::binding::fromPure::sdl::tests::model::Team { name: String[1]; @@ -473,7 +490,7 @@ function <> meta::external::query::graphQL::binding::fromPure::sdl::t let res = typesToGraphQLString([GSEmployee, Employee, Person]); assertEquals( - 'type Employee implements EmployeeInterface @extends(class: "Person") {\n' + + 'type Employee implements EmployeeInterface & PersonInterface @extends(class: "Person") {\n' + ' title: String!\n' + ' startDate: StrictDate!\n' + ' firstName: String\n' + @@ -502,7 +519,7 @@ function <> meta::external::query::graphQL::binding::fromPure::sdl::t ' _exists: Employee_bool_exp\n' + '}\n' + '\n' + - 'type GSEmployee implements EmployeeInterface @extends(class: "Employee") {\n' + + 'type GSEmployee implements EmployeeInterface & PersonInterface @extends(class: "Employee") {\n' + ' division: String!\n' + ' title: String!\n' + ' startDate: StrictDate!\n' + @@ -555,6 +572,93 @@ function <> meta::external::query::graphQL::binding::fromPure::sdl::t $res); } +function <> meta::external::query::graphQL::binding::fromPure::sdl::tests::testClassWithDeepMultipleInheritance():Boolean[1] +{ + let res = typesToGraphQLStringWithoutDynamicFilter([GSEmployee, NonGSEmployee, Employee, Person, NonEmployee, SelfEmployed, Contractor]); + + assertEquals( + 'type Contractor implements SelfEmployedInterface & NonEmployeeInterface & PersonInterface @extends(class: "SelfEmployed") {\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'type Employee implements EmployeeInterface & PersonInterface @extends(class: "Person") {\n' + + ' title: String!\n' + + ' startDate: StrictDate!\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'interface EmployeeInterface implements PersonInterface {\n' + + ' title: String!\n' + + ' startDate: StrictDate!\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'type GSEmployee implements EmployeeInterface & PersonInterface @extends(class: "Employee") {\n' + + ' division: String!\n' + + ' title: String!\n' + + ' startDate: StrictDate!\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'type NonEmployee implements NonEmployeeInterface & PersonInterface @extends(class: "Person") {\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'interface NonEmployeeInterface implements PersonInterface {\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'type NonGSEmployee implements EmployeeInterface & PersonInterface @extends(class: "Employee") {\n' + + ' company: String!\n' + + ' title: String!\n' + + ' startDate: StrictDate!\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'type Person implements PersonInterface {\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'interface PersonInterface {\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'type SelfEmployed implements SelfEmployedInterface & NonEmployeeInterface & PersonInterface @extends(class: "NonEmployee") {\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'interface SelfEmployedInterface implements NonEmployeeInterface & PersonInterface {\n' + + ' firstName: String\n' + + ' lastName: String!\n' + + ' age: Int!\n' + + '}\n' + + '\n' + + 'scalar StrictDate\n' + + '\n' + + 'directive @extends(class: String!) on OBJECT | INPUT_OBJECT', + $res); +} + function <> meta::external::query::graphQL::binding::fromPure::sdl::tests::testPropertyWithInheritance():Boolean[1] { let res = typesToGraphQLString([Team, Employee, Person]); diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/toPure/sdl/tests/simpleTest.pure b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/toPure/sdl/tests/simpleTest.pure index ec1033874a3..a42cab86264 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/toPure/sdl/tests/simpleTest.pure +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-pure/src/main/resources/core_external_query_graphql/binding/toPure/sdl/tests/simpleTest.pure @@ -382,7 +382,7 @@ function <> meta::external::query::graphQL::binding::toPure::sdl::tes let pureTypes = graphQLToPure( '#GQL{' + - 'type Employee implements EmployeeInterface @extends(class: "Person") {\n' + + 'type Employee implements EmployeeInterface & PersonInterface @extends(class: "Person") {\n' + ' title: String!\n' + ' startDate: StrictDate!\n' + ' firstName: String\n' + @@ -398,7 +398,7 @@ function <> meta::external::query::graphQL::binding::toPure::sdl::tes ' age: Int!\n' + '}\n' + '\n' + - 'type GSEmployee implements EmployeeInterface @extends(class: "Employee") {\n' + + 'type GSEmployee implements EmployeeInterface & PersonInterface @extends(class: "Employee") {\n' + ' division: String!\n' + ' title: String!\n' + ' startDate: StrictDate!\n' + diff --git a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-relational-extension/pom.xml b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-relational-extension/pom.xml index fc0cebde0e5..55d9c5bb0fd 100644 --- a/legend-engine-xts-graphQL/legend-engine-xt-graphQL-relational-extension/pom.xml +++ b/legend-engine-xts-graphQL/legend-engine-xt-graphQL-relational-extension/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-graphQL - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-graphQL/pom.xml b/legend-engine-xts-graphQL/pom.xml index 3aa75eb6ae7..082b25a7a11 100644 --- a/legend-engine-xts-graphQL/pom.xml +++ b/legend-engine-xts-graphQL/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-haskell/legend-engine-xt-haskell-grammar/pom.xml b/legend-engine-xts-haskell/legend-engine-xt-haskell-grammar/pom.xml index c5ac35c116a..02681745a8a 100644 --- a/legend-engine-xts-haskell/legend-engine-xt-haskell-grammar/pom.xml +++ b/legend-engine-xts-haskell/legend-engine-xt-haskell-grammar/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-haskell org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-haskell/legend-engine-xt-haskell-protocol/pom.xml b/legend-engine-xts-haskell/legend-engine-xt-haskell-protocol/pom.xml index eb3d7b643cf..56a1493bba5 100644 --- a/legend-engine-xts-haskell/legend-engine-xt-haskell-protocol/pom.xml +++ b/legend-engine-xts-haskell/legend-engine-xt-haskell-protocol/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-haskell org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-haskell/legend-engine-xt-haskell-pure/pom.xml b/legend-engine-xts-haskell/legend-engine-xt-haskell-pure/pom.xml index d08853a9f4e..ff8f3374b68 100644 --- a/legend-engine-xts-haskell/legend-engine-xt-haskell-pure/pom.xml +++ b/legend-engine-xts-haskell/legend-engine-xt-haskell-pure/pom.xml @@ -18,7 +18,7 @@ legend-engine-xts-haskell org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-haskell/pom.xml b/legend-engine-xts-haskell/pom.xml index 25e770c524a..379fa3544fa 100644 --- a/legend-engine-xts-haskell/pom.xml +++ b/legend-engine-xts-haskell/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/pom.xml b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/pom.xml index 0ebb2181246..ec865c90229 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/pom.xml +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-hostedService - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java index f2c8d85e4f0..3b9cb4ac6c7 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java @@ -26,14 +26,12 @@ import org.finos.legend.engine.functionActivator.service.FunctionActivatorError; import org.finos.legend.engine.functionActivator.service.FunctionActivatorService; import org.finos.legend.engine.language.hostedService.generation.deployment.HostedServiceDeploymentManager; -import org.finos.legend.engine.protocol.hostedService.deployment.model.GenerationInfoData; import org.finos.legend.engine.protocol.hostedService.deployment.HostedServiceDeploymentResult; import org.finos.legend.engine.language.hostedService.generation.HostedServiceArtifactGenerator; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; +import org.finos.legend.engine.protocol.hostedService.deployment.HostedServiceDestination; import org.finos.legend.engine.protocol.hostedService.metamodel.HostedServiceProtocolExtension; -import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContext; -import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.shared.core.identity.Identity; import org.finos.legend.pure.generated.*; @@ -124,12 +122,15 @@ public HostedServiceDeploymentResult publishToSandbox(Identity identity, PureMod MutableList validationErrors = this.validate(identity, pureModel, activator, inputModel, routerExtensions); if (validationErrors.isEmpty()) { - GenerationInfoData generation = this.hostedServiceArtifactgenerator.renderArtifact(pureModel, activator, inputModel, "vX_X_X", routerExtensions); - HostedServiceArtifact artifact = new HostedServiceArtifact(activator._pattern(), generation, HostedServiceArtifactGenerator.fetchHostedService(activator, (PureModelContextData) inputModel, pureModel), ((Root_meta_external_function_activator_DeploymentOwnership) activator._ownership())._id(), ((PureModelContextData) inputModel).origin != null ? (AlloySDLC) ((PureModelContextData) inputModel).origin.sdlcInfo : null); - return this.hostedServiceDeploymentManager.deploy(identity, artifact, runtimeConfigs); + HostedServiceArtifact artifact = this.hostedServiceArtifactgenerator.renderServiceArtifact(pureModel, activator, inputModel, "vX_X_X", routerExtensions); + HostedServiceDeploymentResult result = this.hostedServiceDeploymentManager.deploy(identity, artifact, runtimeConfigs); + if (result.successful) + { + result.actionResults = this.hostedServiceDeploymentManager.deployActions(identity, artifact); + } + return result; } return new HostedServiceDeploymentResult(validationErrors.collect(v -> v.message)); } - } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/pom.xml b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/pom.xml index 51146310111..ebccfcc1e79 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/pom.xml +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-hostedService - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -81,6 +81,10 @@ org.finos.legend.engine legend-engine-language-pure-compiler + + org.finos.legend.engine + legend-engine-xt-functionActivator-compiler + diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/src/main/java/org/finos/legend/engine/language/hostedService/compiler/toPureGraph/HostedServiceCompilerExtension.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/src/main/java/org/finos/legend/engine/language/hostedService/compiler/toPureGraph/HostedServiceCompilerExtension.java index e20aaca0651..9cfd888d8b2 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/src/main/java/org/finos/legend/engine/language/hostedService/compiler/toPureGraph/HostedServiceCompilerExtension.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-compiler/src/main/java/org/finos/legend/engine/language/hostedService/compiler/toPureGraph/HostedServiceCompilerExtension.java @@ -18,6 +18,7 @@ import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.code.core.CoreFunctionActivatorCodeRepositoryProvider; +import org.finos.legend.engine.language.functionActivator.compiler.toPureGraph.postDeployment.HelperPostDeploymentCompilerBuilder; import org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext; import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.Processor; @@ -97,6 +98,7 @@ public Root_meta_external_function_activator_hostedService_HostedService buildHo ._generateLineage(app.generateLineage) ._storeModel(app.storeModel) ._ownership(buildHostedServiceOwner(app.ownership, context)) + ._actions(HelperPostDeploymentCompilerBuilder.resolveDeploymentAction(app.actions, context)) ._activationConfiguration(app.activationConfiguration != null ? buildDeploymentConfig((HostedServiceDeploymentConfiguration) app.activationConfiguration, context) : null); } catch (Exception e) @@ -105,7 +107,6 @@ public Root_meta_external_function_activator_hostedService_HostedService buildHo } } - public Root_meta_external_function_activator_Ownership buildHostedServiceOwner(Ownership owner, CompileContext context) { if (owner instanceof UserList) diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml index f2cd30da583..e5d9e5975dc 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-hostedService - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -85,6 +85,10 @@ org.finos.legend.engine legend-engine-xt-functionActivator-pure + + org.finos.legend.engine + legend-engine-xt-functionActivator-generation + diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java index f049796b010..8fb9839e8a4 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java @@ -20,24 +20,31 @@ import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.list.MutableList; +import org.finos.legend.engine.functionActivator.postDeployment.PostDeploymentActionLoader; import org.finos.legend.engine.plan.generation.extension.PlanGeneratorExtension; import org.finos.legend.engine.plan.generation.transformers.PlanTransformer; +import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; +import org.finos.legend.engine.protocol.hostedService.deployment.HostedServiceArtifact; import org.finos.legend.engine.protocol.hostedService.deployment.model.GenerationInfoData; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.engine.plan.generation.PlanGenerator; import org.finos.legend.engine.plan.platform.PlanPlatform; import org.finos.legend.engine.protocol.hostedService.deployment.model.lineage.Lineage; import org.finos.legend.engine.protocol.hostedService.metamodel.HostedService; +import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContext; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.CompositeExecutionPlan; import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.ExecutionPlan; import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan; +import org.finos.legend.pure.generated.Root_meta_external_function_activator_DeploymentOwnership; +import org.finos.legend.pure.generated.Root_meta_external_function_activator_FunctionActivator; import org.finos.legend.pure.generated.Root_meta_external_function_activator_hostedService_HostedService; import org.finos.legend.pure.generated.Root_meta_pure_extension_Extension; import org.finos.legend.pure.generated.core_hostedservice_generation_generation; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition; +import java.util.List; import java.util.Map; import java.util.ServiceLoader; @@ -54,6 +61,13 @@ public static GenerationInfoData renderArtifact(PureModel pureModel, Root_meta_e return new GenerationInfoData(plan, lineage); } + public static HostedServiceArtifact renderServiceArtifact(PureModel pureModel, Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContext inputModel, String clientVersion, Function> routerExtensions) + { + ExecutionPlan plan = generatePlan(pureModel, activator, inputModel, clientVersion, routerExtensions); + Lineage lineage = new Lineage(); + return new HostedServiceArtifact(activator._pattern(), new GenerationInfoData(plan, lineage), HostedServiceArtifactGenerator.fetchHostedService(activator, (PureModelContextData)inputModel, pureModel), ((Root_meta_external_function_activator_DeploymentOwnership) activator._ownership())._id(), renderActions(activator), ((PureModelContextData)inputModel).origin != null ? (AlloySDLC) ((PureModelContextData)inputModel).origin.sdlcInfo : null); + } + public static ExecutionPlan generatePlan(PureModel pureModel, Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContext inputModel, String clientVersion,Function> routerExtensions) { ListIterable transformers = generatorExtensions.flatCollect(PlanGeneratorExtension::getExtraPlanTransformers); @@ -101,4 +115,9 @@ public static String fullName(org.finos.legend.engine.protocol.pure.v1.model.pac return e._package + "::" + e.name; } + public static List renderActions(Root_meta_external_function_activator_FunctionActivator activator) + { + return PostDeploymentActionLoader.generateActions(activator); + } + } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java index bd67a2ea2d2..111f9f95ac1 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java @@ -20,6 +20,7 @@ import org.eclipse.collections.api.block.function.Function; import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.list.MutableList; +import org.finos.legend.engine.functionActivator.postDeployment.PostDeploymentActionLoader; import org.finos.legend.engine.language.hostedService.generation.HostedServiceArtifactGenerator; import org.finos.legend.engine.protocol.hostedService.deployment.HostedServiceArtifact; import org.finos.legend.engine.protocol.hostedService.deployment.model.GenerationInfoData; @@ -79,15 +80,7 @@ public List generate(PackageableElement element, PureModel pureModel, Function> routerExtensions = (PureModel p) -> PureCoreExtensionLoader.extensions().flatCollect(e -> e.extraPureCoreExtensions(p.getExecutionSupport())); GenerationInfoData info = HostedServiceArtifactGenerator.renderArtifact(pureModel, activator, data, clientVersion, routerExtensions); PureModelContextData serviceData = HostedServiceArtifactGenerator.fetchHostedService(activator, data, pureModel); - result.add(new Artifact(mapper.writeValueAsString(new HostedServiceArtifact(activator._pattern(), info, generatePointerForActivator(serviceData, data), ((Root_meta_external_function_activator_DeploymentOwnership)activator._ownership())._id(), (AlloySDLC) data.origin.sdlcInfo)), FILE_NAME, "json")); - if (!(element._stereotypes().anySatisfy(stereotype -> - stereotype._profile()._name().equals("devStatus") && stereotype._profile()._p_stereotypes().anySatisfy(s -> s._value().equals("inProgress"))))) - { - //lineage - LOGGER.info("Generating hostedService lineage artifacts for " + element.getName()); - String lineage = HostedServiceArtifactGenerator.generateLineage(pureModel, activator, data, routerExtensions); - result.add(new Artifact(lineage, LINEAGE_FILE_NAME, "json")); - } + result.add(new Artifact(mapper.writeValueAsString(new HostedServiceArtifact(activator._pattern(), info, generatePointerForActivator(serviceData, data), ((Root_meta_external_function_activator_DeploymentOwnership)activator._ownership())._id(), PostDeploymentActionLoader.generateActions(activator), (AlloySDLC) data.origin.sdlcInfo)), FILE_NAME, "json")); LOGGER.info("Generated artifacts for " + element.getName()); } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/pom.xml b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/pom.xml index a55dc11e3df..ef180ba5c63 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/pom.xml +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-hostedService - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -100,6 +100,11 @@ + + org.finos.legend.engine + legend-engine-xt-functionActivator-grammar + ${project.version} + org.finos.legend.engine legend-engine-language-pure-grammar diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceLexerGrammar.g4 b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceLexerGrammar.g4 index 5e0c8ecd8ae..524701a1df8 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceLexerGrammar.g4 +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceLexerGrammar.g4 @@ -41,6 +41,8 @@ SERVICE_POST_VALIDATION_DESCRIPTION: 'description'; SERVICE_POST_VALIDATION_PARAMETERS: 'params'; SERVICE_POST_VALIDATION_ASSERTIONS: 'assertions'; +// -------------------------------------- POST_DEPLOYMENT_ACTIONS------------------------- +POST_DEPLOYMENT_ACTIONS: 'actions'; // -------------------------------------- EXECUTION_ENVIRONMENT------------------------- diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceParserGrammar.g4 b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceParserGrammar.g4 index 6b8d78d545f..076045a241b 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceParserGrammar.g4 +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/HostedServiceParserGrammar.g4 @@ -21,7 +21,7 @@ identifier: VALID_STRING | STRING | SERVICE_TEST_SERIALIZATION_FORMAT | PARAM_GROUP | ASSERT_FOR_KEYS | SERVICE_POST_VALIDATION | SERVICE_POST_VALIDATION_DESCRIPTION | SERVICE_POST_VALIDATION_PARAMETERS | SERVICE_POST_VALIDATION_ASSERTIONS | EXEC_ENV| SERVICE_EXECUTION_EXECUTIONS | SERVICE_OWNERSHIP_USERLIST |SERVICE_OWNERSHIP_USERLIST_USERS - | SERVICE_OWNERSHIP_DEPLOYMENT | SERVICE_OWNERSHIP_DEPLOYMENT_IDENTIFIER + | SERVICE_OWNERSHIP_DEPLOYMENT | SERVICE_OWNERSHIP_DEPLOYMENT_IDENTIFIER | POST_DEPLOYMENT_ACTIONS ; @@ -50,9 +50,24 @@ service: SERVICE stereotypes? taggedValues? quali | serviceActivationConfiguration | serviceLineage | serviceModel + | postDeploymentActions )* BRACE_CLOSE ; +postDeploymentActions: POST_DEPLOYMENT_ACTIONS COLON + BRACKET_OPEN + (postDeploymentAction (COMMA postDeploymentAction)*)? + BRACKET_CLOSE + SEMI_COLON +; +postDeploymentAction: actionType (actionBody)? +; +actionBody: ISLAND_OPEN actionValue +; +actionValue: (ISLAND_START | ISLAND_BRACE_OPEN | ISLAND_CONTENT | ISLAND_BRACE_CLOSE | ISLAND_END)* +; +actionType: VALID_STRING +; stereotypes: LESS_THAN LESS_THAN stereotype (COMMA stereotype)* GREATER_THAN GREATER_THAN ; stereotype: qualifiedName DOT identifier diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/from/HostedServiceTreeWalker.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/from/HostedServiceTreeWalker.java index d628f08e450..ecfdd2b9e09 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/from/HostedServiceTreeWalker.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/from/HostedServiceTreeWalker.java @@ -17,19 +17,24 @@ import java.util.Collections; import java.util.List; import java.util.function.Consumer; +import java.util.function.Function; import org.antlr.v4.runtime.CharStream; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.language.functionActivator.grammar.postDeployment.from.IPostDeploymentActionGrammarParserExtension; +import org.finos.legend.engine.language.functionActivator.grammar.postDeployment.from.PostDeploymentActionSourceCode; import org.finos.legend.engine.language.pure.grammar.from.ParseTreeWalkerSourceInformation; import org.finos.legend.engine.language.pure.grammar.from.PureGrammarParserContext; import org.finos.legend.engine.language.pure.grammar.from.PureGrammarParserUtility; import org.finos.legend.engine.language.pure.grammar.from.antlr4.HostedServiceParserGrammar; import org.finos.legend.engine.language.pure.grammar.from.runtime.RuntimeParser; +import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; import org.finos.legend.engine.protocol.functionActivator.metamodel.DeploymentOwner; import org.finos.legend.engine.protocol.hostedService.metamodel.HostedService; import org.finos.legend.engine.protocol.hostedService.metamodel.HostedServiceDeploymentConfiguration; import org.finos.legend.engine.protocol.hostedService.metamodel.control.UserList; import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; +import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer; import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementType; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; @@ -114,9 +119,38 @@ private HostedService visitHostedService(HostedServiceParserGrammar.ServiceConte HostedServiceParserGrammar.ServiceAutoActivateUpdatesContext autoActivateUpdatesContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.serviceAutoActivateUpdates(), "autoActivateUpdates", hostedService.sourceInformation); hostedService.autoActivateUpdates = autoActivateUpdatesContext != null && Boolean.parseBoolean(autoActivateUpdatesContext.BOOLEAN().getText()); + HostedServiceParserGrammar.PostDeploymentActionsContext postDeploymentActionsContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.postDeploymentActions(), "actions", hostedService.sourceInformation); + hostedService.actions = postDeploymentActionsContext == null ? Lists.mutable.empty() : this.visitPostDeploymentActions(postDeploymentActionsContext); return hostedService; } + private List visitPostDeploymentActions(HostedServiceParserGrammar.PostDeploymentActionsContext ctx) + { + List specifications = ctx.postDeploymentAction(); + List extensions = IPostDeploymentActionGrammarParserExtension.getExtensions(); + List> parsers = ListIterate.flatCollect(extensions, IPostDeploymentActionGrammarParserExtension::getExtraPostDeploymentActionParsers); + return ListIterate.collect(specifications, spec -> visitPostDeploymentAction(spec, parsers)); + } + + public PostDeploymentAction visitPostDeploymentAction(HostedServiceParserGrammar.PostDeploymentActionContext spec, List> parsers) + { + SourceInformation sourceInformation = walkerSourceInformation.getSourceInformation(spec); + PostDeploymentActionSourceCode code = new PostDeploymentActionSourceCode( + spec.actionBody().actionValue().getText(), + spec.actionType().getText(), + sourceInformation, + ParseTreeWalkerSourceInformation.offset(walkerSourceInformation, spec.getStart()) + ); + + PostDeploymentAction processor = IPostDeploymentActionGrammarParserExtension.process(code, parsers); + + if (processor == null) + { + throw new EngineException("Unsupported syntax", this.walkerSourceInformation.getSourceInformation(spec), EngineErrorType.PARSER); + } + return processor; + } + private List visitTaggedValues(HostedServiceParserGrammar.TaggedValuesContext ctx) { return ListIterate.collect(ctx.taggedValue(), taggedValueContext -> diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/to/HostedServiceGrammarComposer.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/to/HostedServiceGrammarComposer.java index aaf674c2003..4e8c52a9fb5 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/to/HostedServiceGrammarComposer.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-grammar/src/main/java/org/finos/legend/engine/language/hostedService/grammar/to/HostedServiceGrammarComposer.java @@ -38,6 +38,7 @@ import static org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposer.buildSectionComposer; import static org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.convertString; import static org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.getTabString; +import static org.finos.legend.engine.language.functionActivator.grammar.postDeployment.to.PostDeploymentActionGrammarComposer.renderActions; public class HostedServiceGrammarComposer implements PureGrammarComposerExtension { @@ -88,6 +89,7 @@ private static String renderHostedService(HostedService app) " function : " + app.function.path + ";\n" + (app.documentation == null ? "" : " documentation : '" + app.documentation + "';\n") + " autoActivateUpdates : " + app.autoActivateUpdates + ";\n" + + (app.actions.isEmpty() ? "" : renderActions(app.actions) + "\n") + "}"; } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/pom.xml b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/pom.xml index 00ef03b5653..9909eec16a2 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/pom.xml +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-hostedService - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java index 3fdfa326d69..cb718c50e85 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceArtifact.java @@ -15,9 +15,11 @@ package org.finos.legend.engine.protocol.hostedService.deployment; import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; +import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; import org.finos.legend.engine.protocol.hostedService.deployment.model.GenerationInfo; import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContext; +import java.util.List; public class HostedServiceArtifact extends FunctionActivatorArtifact { @@ -33,11 +35,17 @@ public HostedServiceArtifact(String pattern, GenerationInfo info, String ownersh this.version = sdlc != null ? getVersionInfo(sdlc) : null; } - public HostedServiceArtifact(String pattern, GenerationInfo info, PureModelContext serviceData, String ownership,AlloySDLC sdlc) + public HostedServiceArtifact(String pattern, GenerationInfo info, PureModelContext serviceData, String ownership, AlloySDLC sdlc) { this.content = new HostedServiceContent(pattern, info, serviceData, ownership); this.version = sdlc != null ? getVersionInfo(sdlc) : null; } + public HostedServiceArtifact(String pattern, GenerationInfo info, PureModelContext serviceData, String ownership, List actions, AlloySDLC sdlc) + { + this.content = new HostedServiceContent(pattern, info, serviceData, ownership); + this.version = sdlc != null ? getVersionInfo(sdlc) : null; + this.actions = actions; + } } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java index 4faf57a322e..6cb62072285 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-protocol/src/main/java/org/finos/legend/engine/protocol/hostedService/deployment/HostedServiceDeploymentResult.java @@ -14,7 +14,7 @@ package org.finos.legend.engine.protocol.hostedService.deployment; -import org.eclipse.collections.api.list.MutableList; +import java.util.List; import org.finos.legend.engine.protocol.functionActivator.deployment.DeploymentResult; public class HostedServiceDeploymentResult extends DeploymentResult @@ -22,14 +22,14 @@ public class HostedServiceDeploymentResult extends DeploymentResult public String error; public String deployed; public String generationId; - public MutableList errors; + public List errors; public HostedServiceDeploymentResult() { //jackson } - public HostedServiceDeploymentResult(MutableList errors) + public HostedServiceDeploymentResult(List errors) { this.errors = errors; } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/pom.xml b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/pom.xml index c6522e77ef8..d71f0e26451 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/pom.xml +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-hostedService - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/generation/generation.pure b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/generation/generation.pure index dda6942d6d2..729ca6a0d47 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/generation/generation.pure +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/generation/generation.pure @@ -43,8 +43,8 @@ function meta::external::function::activator::hostedService::validator::validate let params = $h.function->functionType().parameters->evaluateAndDeactivate(); let oneParams = $params->filter(p|$p->deactivate().multiplicity == PureOne); let nonOneParams = $params->filter(p|!$p->deactivate().multiplicity == PureOne); - //all [1] params in pattern - $oneParams->map(p| assert($pattern->contains('{'+$p.name+'}'), 'Parameter '+$p.name+' with multiplicty [1] must be in service pattern.')); + //all [1] params in pattern TODO + //$oneParams->map(p| assert($pattern->contains('{'+$p.name+'}'), 'Parameter "'+$p.name+'"" with multiplicty [1] must be in service pattern.')); //all non [1] params not in pattern $nonOneParams->map(p| assert($pattern->contains('{'+$p.name+'}'), 'Parameter '+$p.name+' with multiplicty not [1] cannot be in service pattern.')); //Service has a base pattern @@ -154,41 +154,27 @@ function meta::external::function::activator::hostedService::generation::isMulti function meta::external::function::activator::hostedService::generation::getEnvironmentkey(h:HostedService[1] ):String[1] { let func = $h.function; - let valueSpecification = $func->cast(@ConcreteFunctionDefinition).expressionSequence->cast(@SimpleFunctionExpression)->evaluateAndDeactivate().parametersValues - ->filter(x| $x.genericType.rawType->toOne()->in([ExecutionEnvironmentInstance, SingleExecutionParameters])); - //today we'll get a function cos we're in the pure IDE. from syudio we should be getting a packageable element so the need for the inner match will be eliminated - $valueSpecification->match([ - s:SimpleFunctionExpression[1]| $s->evaluateAndDeactivate().parametersValues->filter(x| $x.genericType.rawType->toOne()==String)->map(pv| - $pv->match([ - v:VariableExpression[1]| $v.name; - ]); - )->toOne();, - a:Any[1]| fail('unexpected type'); 'any'; - ]) ; + let exprs = meta::pure::functions::meta::findExpressionsForFunctionInFunctionDefinition($func->cast(@ConcreteFunctionDefinition),multiExecFuncs()); + let pv = $exprs->first()->toOne('Found no multiExecution expressions')->cast(@SimpleFunctionExpression).parametersValues->at(1); + assert($pv->instanceOf(VariableExpression)); + $pv->cast(@VariableExpression).name; } function meta::external::function::activator::hostedService::generation::getExecutionParam(func: PackageableFunction[1]):PackageableElement[*] +{ + let exprs = meta::pure::functions::meta::findExpressionsForFunctionInFunctionDefinition($func->cast(@ConcreteFunctionDefinition),multiExecFuncs()); + let elements = $exprs ->map(e| $e.parametersValues->at(0)->reactivate()); + $elements->cast(@PackageableElement); +} + +function meta::external::function::activator::hostedService::generation::multiExecFuncs(): Function[*] { - let valueSpecification = $func->cast(@ConcreteFunctionDefinition).expressionSequence->cast(@SimpleFunctionExpression)->evaluateAndDeactivate().parametersValues - ->filter(x| $x.genericType.rawType->toOne()->in([ExecutionEnvironmentInstance, SingleExecutionParameters, DataSpace, DataSpaceExecutionContext])); - //today we'll get a function cos we're in the pure IDE. from syudio we should be getting a packageable element so the need for the inner match will be eliminated - if($valueSpecification->isNotEmpty(), - |$valueSpecification->match([ - s:SimpleFunctionExpression[1]|if($s.func->in([get_ExecutionEnvironmentInstance_1__String_1__SingleExecutionParameters_1_, get_DataSpace_1__String_1__DataSpaceExecutionContext_1_ ]), - |$s->evaluateAndDeactivate().parametersValues->filter(x| $x.genericType.rawType->toOne()->in([ExecutionEnvironmentInstance, DataSpace]))->map(pv| - $pv->match([ - s:SimpleFunctionExpression[1]| $s->reactivate()->toOne();, - i:InstanceValue[1]| $i.values->toOne();, - e: ExecutionEnvironmentInstance[1]| $e - ]));, - |$s->reactivate()->toOne() - );, - e: ExecutionEnvironmentInstance[1]| $e, - d: DataSpace[1] | $d, - a:Any[1]| fail('unexpected type'); $a; - ]), - |[])->cast(@PackageableElement); + [ + getWithRuntime_ExecutionEnvironmentInstance_1__String_1__String_1__SingleExecutionParameters_1_, + get_ExecutionEnvironmentInstance_1__String_1__SingleExecutionParameters_1_, + get_DataSpace_1__String_1__DataSpaceExecutionContext_1_ + ] } function meta::external::function::activator::hostedService::generation::rebuildServiceUsingFlattenedParams(h:HostedService[1] ):Pair[*] @@ -196,12 +182,7 @@ function meta::external::function::activator::hostedService::generation::rebuild let execParam = getExecutionParam($h.function); $execParam->match([ e : ExecutionEnvironmentInstance[*] | assert($e->size()== 1, 'Found too many/not enough execution environment instances. Size='+ $e->size()->toString()); - $e.executionParameters->map( - p | assert($p->instanceOf(SingleExecutionParameters),'Only handles singleExecutionParams'); - let newFunc = rebuildFromExpression($h.function, $p->cast(@SingleExecutionParameters).mapping, $p->cast(@SingleExecutionParameters).runtime); - let newHostedService = ^$h(function=$newFunc); - pair($p->cast(@SingleExecutionParameters).key, $newHostedService); - );, + rebuildFromExpressionForExecutionEnv($h, $e->cast(@ExecutionEnvironmentInstance)->toOne());, d : DataSpace[*] | assert($d->size() == 1, 'Found too many/ not enough dataSpaces, Size =' + $d->size()->toString()); $d.executionContexts->map( ec | let newFunc = rebuildFromExpression($h.function, $ec.mapping, $ec.defaultRuntime.runtimeValue); @@ -212,6 +193,67 @@ function meta::external::function::activator::hostedService::generation::rebuild ]); } +function meta::external::function::activator::hostedService::generation::rebuildFromExpressionForExecutionEnv(h:HostedService[1], e:ExecutionEnvironmentInstance[1]): Pair[*] +{ + + let shouldMergeRuntime = meta::pure::functions::meta::findExpressionsForFunctionInFunctionDefinition($h.function->cast(@ConcreteFunctionDefinition),getWithRuntime_ExecutionEnvironmentInstance_1__String_1__String_1__SingleExecutionParameters_1_)->isNotEmpty(); + if($shouldMergeRuntime, + |$e.executionParameters->map( + p | assert($p->instanceOf(SingleExecutionParameters),'Only handles singleExecutionParams'); + let newFunc = rewriteUsingRuntimeComponents($h.function->cast(@ConcreteFunctionDefinition), $p->cast(@SingleExecutionParameters)); + let newHostedService = ^$h(function=$newFunc); + pair($p->cast(@SingleExecutionParameters).key, $newHostedService); + ), + | + $e.executionParameters->map( + p | assert($p->instanceOf(SingleExecutionParameters),'Only handles singleExecutionParams'); + let newFunc = rebuildFromExpression($h.function, $p->cast(@SingleExecutionParameters).mapping, $p->cast(@SingleExecutionParameters).runtime->toOne()); + let newHostedService = ^$h(function=$newFunc); + pair($p->cast(@SingleExecutionParameters).key, $newHostedService); + ) + ); +} + +function meta::external::function::activator::hostedService::generation::rewriteUsingRuntimeComponents(originalFunction:ConcreteFunctionDefinition[1], execParam :meta::legend::service::metamodel::SingleExecutionParameters[1] ): ConcreteFunctionDefinition[1] +{ + let getWithRuntime = meta::pure::functions::meta::findExpressionsForFunctionInFunctionDefinition($originalFunction->cast(@ConcreteFunctionDefinition),getWithRuntime_ExecutionEnvironmentInstance_1__String_1__String_1__SingleExecutionParameters_1_); + let runtimeComp = $execParam.runtimeComponents; + let getWithModelQueryExpression = ^SimpleFunctionExpression(genericType=^GenericType(rawType = Runtime), + multiplicity=PureOne, + func= meta::core::runtime::getRuntimeWithModelQueryConnection_Class_1__Binding_1__String_1__Runtime_1_, + importGroup = system::imports::coreImport, + parametersValues = [ + ^InstanceValue(genericType=^GenericType(rawType = Class),multiplicity=PureOne, values = [$runtimeComp.class]), + ^InstanceValue(genericType=^GenericType(rawType = Binding),multiplicity=PureOne, values = [$runtimeComp.binding]), + $getWithRuntime->cast(@SimpleFunctionExpression).parametersValues->last()->toOne()->cast(@VariableExpression) + ] + ); + let mergeRuntimeExpression = ^SimpleFunctionExpression(genericType=^GenericType(rawType = Runtime), + multiplicity=PureOne, + func= meta::core::runtime::mergeRuntimes_Any_$1_MANY$__Runtime_1_, + importGroup = system::imports::coreImport, + parametersValues = [ + ^InstanceValue(genericType=^GenericType(rawType = Any),multiplicity=ZeroMany, values = [$getWithModelQueryExpression , $runtimeComp.runtime->toOne()]) + ] + ); + let serializeExpr =$originalFunction.expressionSequence->toOne()->cast(@SimpleFunctionExpression); + let fromExpr = $serializeExpr->evaluateAndDeactivate().parametersValues; + let newFrom = ^SimpleFunctionExpression( + importGroup = system::imports::coreImport, + functionName = 'from', + func = meta::pure::mapping::from_T_m__Mapping_1__Runtime_1__T_m_, + genericType = $fromExpr->at(0).genericType, + multiplicity = PureOne, + parametersValues = $fromExpr->at(0)->cast(@SimpleFunctionExpression)->evaluateAndDeactivate().parametersValues->at(0) + ->concatenate(^InstanceValue(genericType =^GenericType(rawType = Mapping), multiplicity = PureOne, values = $execParam->at(0)->cast(@meta::legend::service::metamodel::SingleExecutionParameters).mapping)) + ->concatenate(^InstanceValue(genericType =^GenericType(rawType = Runtime), multiplicity = PureOne, values = $mergeRuntimeExpression)) + )->evaluateAndDeactivate(); + ^$originalFunction( + expressionSequence = ^$serializeExpr(parametersValues = $newFrom->concatenate($fromExpr->tail())) + ); + +} + function meta::external::function::activator::hostedService::generation::rebuildFromExpression(func: PackageableFunction[1], mapping: Mapping[1], runtime: Runtime[1]): PackageableFunction[1] { let fromExpression = ^SimpleFunctionExpression( diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/showcase/showcaseServices.pure b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/showcase/showcaseServices.pure index 96979c0be09..4ac222be8bd 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/showcase/showcaseServices.pure +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-pure/src/main/resources/core_hostedservice/showcase/showcaseServices.pure @@ -1,3 +1,7 @@ +import meta::legend::service::metamodel::*; +import meta::legend::service::*; +import meta::external::store::model::*; +import meta::core::runtime::*; import meta::external::function::activator::*; import meta::external::function::activator::hostedService::generation::*; import meta::external::format::shared::functions::*; @@ -76,7 +80,77 @@ function meta::external::function::activator::hostedService::tests::simplefuncti } +function meta::external::function::activator::hostedService::tests::simpleServiceMergeRuntime():Any[*] +{ + let extensions = meta::external::format::shared::externalFormatExtension()->concatenate(meta::relational::extension::relationalExtensions()); + + let service = ^HostedService + ( + pattern = '/service/{key}/{data}', + ownership = ^UserList(users = ['debelp', 'harted']), + documentation = 'bla bla', + autoActivateUpdates = true, + function= meta::external::function::activator::hostedService::tests::functionWithRuntimeComponents_String_1__String_1__String_1_ + ); + $service->meta::external::function::activator::hostedService::generation::getEnvironmentkey()->println(); + //validate + $service->meta::external::function::activator::hostedService::validator::validateService(); + $service-> meta::external::function::activator::hostedService::generation::isMultiEenvironmentService()->println(); //fail(); + //printlnPlan + $service->rebuildServiceUsingFlattenedParams().second->map(s|$s->meta::external::function::activator::hostedService::generation::printPlan()); +} + +function meta::external::function::activator::hostedService::tests::functionWithRuntimeComponents(key:String[1], data:String[1]):String[1] +{ + meta::external::format::shared::executionPlan::tests::TargetPerson.all() + ->graphFetch(#{meta::external::format::shared::executionPlan::tests::TargetPerson{fullName}}#) + ->from(meta::external::function::activator::hostedService::tests::execEnvInstance()->getWithRuntime($key, $data)) + ->serialize( #{meta::external::format::shared::executionPlan::tests::TargetPerson{fullName}}#); +} + + +function meta::external::function::activator::hostedService::tests::testBindingX(): Binding[1] +{ + ^Binding( + name = 'MyBindingMo', + package = meta::external::format::shared::executionPlan::tests::_Person.package, + contentType = 'application/x.flatdata', + modelUnit = ^ModelUnit() + ); +} + +function meta::external::function::activator::hostedService::tests::execEnvInstance():meta::legend::service::metamodel::ExecutionEnvironmentInstance[1] +{ + let runtime2 = ^meta::core::runtime::Runtime( + connectionStores = ^ConnectionStore( + element=^ModelStore(), + connection=^ModelChainConnection(mappings = meta::external::format::shared::executionPlan::tests::M2MMapping1)) + ); + ^meta::legend::service::metamodel::ExecutionEnvironmentInstance( + executionParameters = [ + ^meta::legend::service::metamodel::SingleExecutionParameters + ( + key = 'UAT', + mapping = meta::external::format::shared::executionPlan::tests::M2MMapping, + runtimeComponents = ^meta::legend::service::metamodel::RuntimeComponents( + runtime = $runtime2, + class = meta::external::format::shared::executionPlan::tests::_Person, + binding = meta::external::function::activator::hostedService::tests::testBindingX() + ) + ), + ^meta::legend::service::metamodel::SingleExecutionParameters + ( + key = 'PROD', + mapping = meta::external::format::shared::executionPlan::tests::M2MMapping, + runtimeComponents = ^meta::legend::service::metamodel::RuntimeComponents( + runtime = $runtime2, + class = meta::external::format::shared::executionPlan::tests::_Person, + binding = meta::external::function::activator::hostedService::tests::testBindingX() + ) + ) + ]); +} // relational with single execution param @@ -104,20 +178,23 @@ function meta::external::function::activator::hostedService::tests::simpleRelati runtime= meta::external::function::activator::hostedService::tests::testRuntime(dbInc) )) } -// Simple relational with Execution env instance +//Simple relational with Execution env instance function meta::external::function::activator::hostedService::tests::simpleServiceTDSShowcase4():Any[*] { let service = ^HostedService ( - pattern = '/service', + pattern = '/service/{env}', ownership = ^UserList(users = ['debelp', 'harted']), documentation = 'bla bla', autoActivateUpdates = true, - function= meta::external::function::activator::hostedService::tests::simpleRelationalfunctionWithExecutionEnvInstance__TabularDataSet_1_ + function= meta::external::function::activator::hostedService::tests::simpleRelationalfunctionWithExecutionEnvInstance_String_1__TabularDataSet_1_ ); //isMulti print('isMultiExecService:'); $service-> meta::external::function::activator::hostedService::generation::isMultiEenvironmentService()->println(); + + $service->meta::external::function::activator::hostedService::generation::getEnvironmentkey()->println(); + //validate $service->meta::external::function::activator::hostedService::validator::validateService(); //printlnPlan @@ -125,12 +202,6 @@ function meta::external::function::activator::hostedService::tests::simpleServic } -function meta::external::function::activator::hostedService::tests::simpleRelationalfunctionWithExecutionEnvInstance():TabularDataSet[1] -{ - PersonX.all()->filter(p|$p.firstName == 'haha')->project([col(p|$p.firstName, 'firstName'), col(p|$p.lastName, 'lastName')]) - ->from(meta::external::function::activator::hostedService::tests::TestExecutionEnviroment()); -} - // Simple relational with Execution env instance function meta::external::function::activator::hostedService::tests::simpleServiceTDSShowcase4X():Any[*] { @@ -163,12 +234,12 @@ function meta::external::function::activator::hostedService::tests::simpleServic { let service = ^HostedService ( - pattern = '/service', + pattern = '/service/{env}', ownership = ^UserList(users = ['debelp', 'harted']), binding = ^Binding(name='serviceBinding', contentType = 'application/json',modelUnit = meta::pure::model::unit::newModelUnit()->include(PersonX)), documentation = 'bla bla', autoActivateUpdates = true, - function= meta::external::function::activator::hostedService::tests::simplegraphFetchfunctionWithExecutionEnvInstance__PersonX_MANY_ + function= meta::external::function::activator::hostedService::tests::simplegraphFetchfunctionWithExecutionEnvInstance_String_1__PersonX_MANY_ ); //validate @@ -182,12 +253,12 @@ function meta::external::function::activator::hostedService::tests::simpleServic { let service = ^HostedService ( - pattern = '/service', + pattern = '/service/{env}', ownership = ^UserList(users = ['debelp', 'harted']), contentType = 'application/json', documentation = 'bla bla', autoActivateUpdates = true, - function= meta::external::function::activator::hostedService::tests::simplegraphFetchfunctionWithExecutionEnvInstance__PersonX_MANY_ + function= meta::external::function::activator::hostedService::tests::simplegraphFetchfunctionWithExecutionEnvInstance_String_1__PersonX_MANY_ ); //isMulti print('isMultiExecService:'); @@ -199,9 +270,9 @@ $service-> meta::external::function::activator::hostedService::generation::isMul } -function meta::external::function::activator::hostedService::tests::simplegraphFetchfunctionWithExecutionEnvInstance():PersonX[*] +function meta::external::function::activator::hostedService::tests::simplegraphFetchfunctionWithExecutionEnvInstance(env:String[1]):PersonX[*] { - PersonX.all()->graphFetch(#{ PersonX {firstName} } #)->from(meta::external::function::activator::hostedService::tests::TestExecutionEnviroment()); + PersonX.all()->graphFetch(#{ PersonX {firstName} } #)->from(meta::external::function::activator::hostedService::tests::TestExecutionEnviroment()->get($env)); } function meta::external::function::activator::hostedService::tests::TestExecutionEnviroment(): meta::legend::service::metamodel::ExecutionEnvironmentInstance[1] @@ -214,6 +285,7 @@ function meta::external::function::activator::hostedService::tests::TestExecutio key = 'UAT', mapping = simpleRelationalMapping, runtime = meta::external::function::activator::hostedService::tests::testRuntime(dbInc) + ), ^meta::legend::service::metamodel::SingleExecutionParameters ( diff --git a/legend-engine-xts-hostedService/pom.xml b/legend-engine-xts-hostedService/pom.xml index 0574558d06c..36a0e99fb29 100644 --- a/legend-engine-xts-hostedService/pom.xml +++ b/legend-engine-xts-hostedService/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-iceberg/legend-engine-xt-iceberg-pure/pom.xml b/legend-engine-xts-iceberg/legend-engine-xt-iceberg-pure/pom.xml index f3e2edff2f6..7ae5c3fe532 100644 --- a/legend-engine-xts-iceberg/legend-engine-xt-iceberg-pure/pom.xml +++ b/legend-engine-xts-iceberg/legend-engine-xt-iceberg-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-iceberg - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-iceberg/legend-engine-xt-iceberg-test-support/pom.xml b/legend-engine-xts-iceberg/legend-engine-xt-iceberg-test-support/pom.xml index 0b9a63cc696..b7dc96bb360 100644 --- a/legend-engine-xts-iceberg/legend-engine-xt-iceberg-test-support/pom.xml +++ b/legend-engine-xts-iceberg/legend-engine-xt-iceberg-test-support/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-iceberg - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-iceberg/pom.xml b/legend-engine-xts-iceberg/pom.xml index 2428f272a20..1645f8ba1cb 100644 --- a/legend-engine-xts-iceberg/pom.xml +++ b/legend-engine-xts-iceberg/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-apiToken/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-apiToken/pom.xml index c6c1af2c81f..07dcdb8b083 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-apiToken/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-apiToken/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-gcp/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-gcp/pom.xml index 4af882d7ac4..f1c28e1c73b 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-gcp/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-gcp/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-kerberos/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-kerberos/pom.xml index 29981e1b917..c8b39efe276 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-kerberos/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-kerberos/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-middletier/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-middletier/pom.xml index 8b72d16b2ec..a57aff10c7a 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-middletier/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-middletier/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-oauth/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-oauth/pom.xml index 279d2db32de..f1397f574b5 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-oauth/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-oauth/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-pac4j/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-pac4j/pom.xml index 82403765f96..6af4052a39e 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-pac4j/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-pac4j/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-plainTextUserPassword/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-plainTextUserPassword/pom.xml index c6a4c03bea6..c6d16ee5aaa 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-plainTextUserPassword/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-plainTextUserPassword/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/legend-engine-xt-identity-privateKey/pom.xml b/legend-engine-xts-identity/legend-engine-xt-identity-privateKey/pom.xml index 02c38d0afb8..0e59c9cfbab 100644 --- a/legend-engine-xts-identity/legend-engine-xt-identity-privateKey/pom.xml +++ b/legend-engine-xts-identity/legend-engine-xt-identity-privateKey/pom.xml @@ -3,7 +3,7 @@ legend-engine-xts-identity org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-identity/pom.xml b/legend-engine-xts-identity/pom.xml index d0dbd84897e..7791df5c0a0 100644 --- a/legend-engine-xts-identity/pom.xml +++ b/legend-engine-xts-identity/pom.xml @@ -3,7 +3,7 @@ legend-engine org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-java/legend-engine-external-language-java/pom.xml b/legend-engine-xts-java/legend-engine-external-language-java/pom.xml index d3549c7ff5d..0799001b69e 100644 --- a/legend-engine-xts-java/legend-engine-external-language-java/pom.xml +++ b/legend-engine-xts-java/legend-engine-external-language-java/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-java - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure/pom.xml b/legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure/pom.xml index cd9139b5c90..f4086283a74 100644 --- a/legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure/pom.xml +++ b/legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-java - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -143,12 +143,10 @@ org.finos.legend.pure legend-pure-m3-core - org.finos.legend.pure legend-pure-runtime-java-engine-compiled - @@ -193,7 +191,17 @@ junit junit - + + org.finos.legend.pure + legend-pure-m3-core + test-jar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + diff --git a/legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreExternalLanguageJavaFeatureBasedGenerationCompiledStateIntegrity.java b/legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreExternalLanguageJavaFeatureBasedGenerationCompiledStateIntegrity.java new file mode 100644 index 00000000000..d503e539a01 --- /dev/null +++ b/legend-engine-xts-java/legend-engine-xt-javaGeneration-featureBased-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreExternalLanguageJavaFeatureBasedGenerationCompiledStateIntegrity.java @@ -0,0 +1,38 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.code.core; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class TestCoreExternalLanguageJavaFeatureBasedGenerationCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_external_language_java_feature_based_generation"); + } + + @Test + @Ignore + @Override + public void testReferenceUsages() + { + // TODO fix this test + super.testReferenceUsages(); + } +} diff --git a/legend-engine-xts-java/legend-engine-xt-javaGeneration-pure/pom.xml b/legend-engine-xts-java/legend-engine-xt-javaGeneration-pure/pom.xml index 01ef3c96a81..0f477cb2237 100644 --- a/legend-engine-xts-java/legend-engine-xt-javaGeneration-pure/pom.xml +++ b/legend-engine-xts-java/legend-engine-xt-javaGeneration-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-java - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -113,17 +113,17 @@ org.finos.legend.pure - legend-pure-m2-dsl-graph-grammar + legend-pure-m2-dsl-diagram-grammar ${legend.pure.version} org.finos.legend.pure - legend-pure-m2-dsl-mapping-grammar + legend-pure-m2-dsl-graph-grammar ${legend.pure.version} org.finos.legend.pure - legend-pure-m2-dsl-diagram-grammar + legend-pure-m2-dsl-mapping-grammar ${legend.pure.version} @@ -197,7 +197,27 @@ junit junit - + + org.finos.legend.pure + legend-pure-m3-core + test-jar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-graph-grammar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-path-grammar + test + diff --git a/legend-engine-xts-java/legend-engine-xt-javaGeneration-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreExternalLanguageJavaCompiledStateIntegrity.java b/legend-engine-xts-java/legend-engine-xt-javaGeneration-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreExternalLanguageJavaCompiledStateIntegrity.java new file mode 100644 index 00000000000..92525262186 --- /dev/null +++ b/legend-engine-xts-java/legend-engine-xt-javaGeneration-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreExternalLanguageJavaCompiledStateIntegrity.java @@ -0,0 +1,38 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.code.core; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class TestCoreExternalLanguageJavaCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_external_language_java"); + } + + @Test + @Ignore + @Override + public void testReferenceUsages() + { + // TODO fix this test + super.testReferenceUsages(); + } +} diff --git a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/pom.xml b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/pom.xml index 62d76c61a65..5fa3933b201 100644 --- a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/pom.xml +++ b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-java - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/src/test/java/org/finos/legend/engine/pure/code/core/java/binding/Test_JAVA_GrammarFunction_PCT.java b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/src/test/java/org/finos/legend/engine/pure/code/core/java/binding/Test_JAVA_GrammarFunction_PCT.java index 6f5e5c1c412..0fc951736e6 100644 --- a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/src/test/java/org/finos/legend/engine/pure/code/core/java/binding/Test_JAVA_GrammarFunction_PCT.java +++ b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-PCT/src/test/java/org/finos/legend/engine/pure/code/core/java/binding/Test_JAVA_GrammarFunction_PCT.java @@ -34,10 +34,12 @@ public class Test_JAVA_GrammarFunction_PCT extends PCTReportConfiguration // Eq one("meta::pure::functions::boolean::tests::equality::eq::testEqNonPrimitive_Function_1__Boolean_1_", "\"Unhandled value type: meta::pure::functions::boolean::tests::equalitymodel::SideClass\""), one("meta::pure::functions::boolean::tests::equality::eq::testEqVarIdentity_Function_1__Boolean_1_", "\"Unhandled value type: meta::pure::functions::boolean::tests::equalitymodel::BottomClass\""), + one("meta::pure::functions::boolean::tests::equality::eq::testEqPrimitiveExtension_Function_1__Boolean_1_", "\"Unsupported type: meta::pure::functions::boolean::tests::equalitymodel::ExtendedInteger\""), // Equal one("meta::pure::functions::boolean::tests::equality::equal::testEqualNonPrimitive_Function_1__Boolean_1_", "\"Unhandled value type: meta::pure::functions::boolean::tests::equalitymodel::SideClass\""), one("meta::pure::functions::boolean::tests::equality::equal::testEqualVarIdentity_Function_1__Boolean_1_", "\"Unhandled value type: meta::pure::functions::boolean::tests::equalitymodel::BottomClass\""), + one("meta::pure::functions::boolean::tests::equality::equal::testEqualPrimitiveExtension_Function_1__Boolean_1_", "\"Unsupported type: meta::pure::functions::boolean::tests::equalitymodel::ExtendedInteger\""), // GreaterThan one("meta::pure::functions::boolean::tests::inequalities::greaterThan::testGreaterThan_Boolean_Function_1__Boolean_1_", "\"Assert failed\""), diff --git a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-externalFormat-pure/pom.xml b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-externalFormat-pure/pom.xml index 4997870ad1a..1fd5db4439c 100644 --- a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-externalFormat-pure/pom.xml +++ b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-externalFormat-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-java - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -151,7 +151,6 @@ org.finos.legend.pure legend-pure-runtime-java-engine-compiled - @@ -195,12 +194,22 @@ junit junit + + org.finos.legend.pure + legend-pure-m3-core + test-jar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + org.finos.legend.engine legend-engine-language-pure-compiler test - diff --git a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-externalFormat-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreJavaPlatformBindingExternalFormatCompiledStateIntegrity.java b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-externalFormat-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreJavaPlatformBindingExternalFormatCompiledStateIntegrity.java new file mode 100644 index 00000000000..80c18ec4157 --- /dev/null +++ b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-externalFormat-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreJavaPlatformBindingExternalFormatCompiledStateIntegrity.java @@ -0,0 +1,38 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.code.core; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class TestCoreJavaPlatformBindingExternalFormatCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_java_platform_binding_external_format"); + } + + @Test + @Ignore + @Override + public void testReferenceUsages() + { + // TODO fix this test + super.testReferenceUsages(); + } +} diff --git a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/pom.xml b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/pom.xml index 28613686a84..b4f6c8c1489 100644 --- a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/pom.xml +++ b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-java - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -229,12 +229,22 @@ junit junit + + org.finos.legend.pure + legend-pure-m3-core + test-jar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + org.finos.legend.engine legend-engine-language-pure-compiler test - diff --git a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/src/main/resources/core_java_platform_binding/legendJavaPlatformBinding/pct_java.pure b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/src/main/resources/core_java_platform_binding/legendJavaPlatformBinding/pct_java.pure index a046d7d58db..00b0b0056f9 100644 --- a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/src/main/resources/core_java_platform_binding/legendJavaPlatformBinding/pct_java.pure +++ b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/src/main/resources/core_java_platform_binding/legendJavaPlatformBinding/pct_java.pure @@ -18,7 +18,7 @@ import meta::pure::executionPlan::platformBinding::localBinding::*; import meta::pure::executionPlan::platformBinding::*; import meta::pure::test::pct::*; -function <> meta::pure::executionPlan::platformBinding::legendJava::pct::testAdapterForJavaBindingExecution(f:Function<{->X[o]}>[1]):X[o] +function <> {PCT.adapterName='Java Platform Binding'} meta::pure::executionPlan::platformBinding::legendJava::pct::testAdapterForJavaBindingExecution(f:Function<{->X[o]}>[1]):X[o] { let debug = noDebug(); diff --git a/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreJavaPlatformBindingCompiledStateIntegrity.java b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreJavaPlatformBindingCompiledStateIntegrity.java new file mode 100644 index 00000000000..fa9461380b9 --- /dev/null +++ b/legend-engine-xts-java/legend-engine-xt-javaPlatformBinding-pure/src/test/java/org/finos/legend/engine/pure/code/core/TestCoreJavaPlatformBindingCompiledStateIntegrity.java @@ -0,0 +1,38 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.code.core; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class TestCoreJavaPlatformBindingCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_java_platform_binding"); + } + + @Test + @Ignore + @Override + public void testReferenceUsages() + { + // TODO fix this test + super.testReferenceUsages(); + } +} diff --git a/legend-engine-xts-java/pom.xml b/legend-engine-xts-java/pom.xml index f64587187e0..e25dfba4531 100644 --- a/legend-engine-xts-java/pom.xml +++ b/legend-engine-xts-java/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-json/legend-engine-external-format-jsonSchema/pom.xml b/legend-engine-xts-json/legend-engine-external-format-jsonSchema/pom.xml index ebc12e24aa8..74a839993a2 100644 --- a/legend-engine-xts-json/legend-engine-external-format-jsonSchema/pom.xml +++ b/legend-engine-xts-json/legend-engine-external-format-jsonSchema/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-json/legend-engine-xt-json-http-api/pom.xml b/legend-engine-xts-json/legend-engine-xt-json-http-api/pom.xml index f54b0b7dd93..4a468ab7129 100644 --- a/legend-engine-xts-json/legend-engine-xt-json-http-api/pom.xml +++ b/legend-engine-xts-json/legend-engine-xt-json-http-api/pom.xml @@ -4,7 +4,7 @@ org.finos.legend.engine legend-engine-xts-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-json-http-api diff --git a/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-pure/pom.xml b/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-pure/pom.xml index d5c5da84e48..0ef0f70ade6 100644 --- a/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-pure/pom.xml +++ b/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -245,5 +245,16 @@ junit junit + + org.finos.legend.pure + legend-pure-m3-core + test-jar + test + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + - \ No newline at end of file + diff --git a/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-pure/src/test/java/org/finos/legend/engine/pure/code/core/json/binding/TestCoreExternalFormatJsonJavaPlatformBindingCompiledStateIntegrity.java b/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-pure/src/test/java/org/finos/legend/engine/pure/code/core/json/binding/TestCoreExternalFormatJsonJavaPlatformBindingCompiledStateIntegrity.java new file mode 100644 index 00000000000..cf0efef0dd4 --- /dev/null +++ b/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-pure/src/test/java/org/finos/legend/engine/pure/code/core/json/binding/TestCoreExternalFormatJsonJavaPlatformBindingCompiledStateIntegrity.java @@ -0,0 +1,38 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.code.core.json.binding; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class TestCoreExternalFormatJsonJavaPlatformBindingCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_external_format_json_java_platform_binding"); + } + + @Test + @Ignore + @Override + public void testReferenceUsages() + { + // TODO fix this test + super.testReferenceUsages(); + } +} diff --git a/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-test/pom.xml b/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-test/pom.xml index a16ee12aa1c..19137275a50 100644 --- a/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-test/pom.xml +++ b/legend-engine-xts-json/legend-engine-xt-json-javaPlatformBinding-test/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-json/legend-engine-xt-json-model/pom.xml b/legend-engine-xts-json/legend-engine-xt-json-model/pom.xml index 7fbeb3bb8b8..5a03ed916f7 100644 --- a/legend-engine-xts-json/legend-engine-xt-json-model/pom.xml +++ b/legend-engine-xts-json/legend-engine-xt-json-model/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-json/legend-engine-xt-json-pure/pom.xml b/legend-engine-xts-json/legend-engine-xt-json-pure/pom.xml index c2d6b2fb232..9813dbf601a 100644 --- a/legend-engine-xts-json/legend-engine-xt-json-pure/pom.xml +++ b/legend-engine-xts-json/legend-engine-xt-json-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -219,14 +219,26 @@ org.eclipse.collections eclipse-collections-api + - org.finos.legend.engine - legend-engine-language-pure-compiler + junit + junit + + + org.finos.legend.pure + legend-pure-m3-core + test-jar test - junit - junit + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + + + org.finos.legend.engine + legend-engine-language-pure-compiler + test - \ No newline at end of file + diff --git a/legend-engine-xts-json/legend-engine-xt-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/json/TestCoreExternalFormatJsonCompiledStateIntegrity.java b/legend-engine-xts-json/legend-engine-xt-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/json/TestCoreExternalFormatJsonCompiledStateIntegrity.java new file mode 100644 index 00000000000..b7bbaa26cce --- /dev/null +++ b/legend-engine-xts-json/legend-engine-xt-json-pure/src/test/java/org/finos/legend/engine/pure/code/core/json/TestCoreExternalFormatJsonCompiledStateIntegrity.java @@ -0,0 +1,38 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.code.core.json; + +import org.finos.legend.pure.m3.tests.AbstractCompiledStateIntegrityTest; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class TestCoreExternalFormatJsonCompiledStateIntegrity extends AbstractCompiledStateIntegrityTest +{ + @BeforeClass + public static void initialize() + { + initialize("core_external_format_json"); + } + + @Test + @Ignore + @Override + public void testReferenceUsages() + { + // TODO fix this test + super.testReferenceUsages(); + } +} diff --git a/legend-engine-xts-json/legend-engine-xt-json-runtime/pom.xml b/legend-engine-xts-json/legend-engine-xt-json-runtime/pom.xml index 6ff630368e1..3ba3c782fc6 100644 --- a/legend-engine-xts-json/legend-engine-xt-json-runtime/pom.xml +++ b/legend-engine-xts-json/legend-engine-xt-json-runtime/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-json - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-json/pom.xml b/legend-engine-xts-json/pom.xml index 45338cbb557..a5d89c36746 100644 --- a/legend-engine-xts-json/pom.xml +++ b/legend-engine-xts-json/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-api/pom.xml b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-api/pom.xml index d75a51b9de8..0a21b333ebd 100644 --- a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-api/pom.xml +++ b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-api/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-memsqlFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-compiler/pom.xml b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-compiler/pom.xml index 792d16cfc35..cdaf272fc57 100644 --- a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-compiler/pom.xml +++ b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-compiler/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-memsqlFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-generator/pom.xml b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-generator/pom.xml index 12ce7f61101..b7d58283ded 100644 --- a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-generator/pom.xml +++ b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-generator/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-memsqlFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-grammar/pom.xml b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-grammar/pom.xml index e5804382052..ce9ec4f9c3a 100644 --- a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-grammar/pom.xml +++ b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-grammar/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-memsqlFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-protocol/pom.xml b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-protocol/pom.xml index 05737a49c3d..ed6b4df03d9 100644 --- a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-protocol/pom.xml +++ b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-memsqlFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-pure/pom.xml b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-pure/pom.xml index e983fd3106b..15bc56bcba7 100644 --- a/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-pure/pom.xml +++ b/legend-engine-xts-memsqlFunction/legend-engine-xt-memsqlFunction-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-memsqlFunction - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-memsqlFunction/pom.xml b/legend-engine-xts-memsqlFunction/pom.xml index 001541ffb12..a55a38fa008 100644 --- a/legend-engine-xts-memsqlFunction/pom.xml +++ b/legend-engine-xts-memsqlFunction/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/pom.xml b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/pom.xml index cff295ec0df..0c322befbe3 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/pom.xml +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-mongodb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStartCommand.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStartCommand.java index 933b8d50e33..126bc81d45a 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStartCommand.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStartCommand.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.engine.plan.execution.stores.mongodb.test.shared.MongoDBCommands; import org.finos.legend.pure.generated.Root_meta_pure_functions_io_http_URL; import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl; @@ -51,7 +52,7 @@ public MongoDBStartCommand(FunctionExecutionInterpreted functionExecution, Model } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance imageTagCoreInstance = params.get(0); String imageTag = Instance.getValueForMetaPropertyToOneResolved(imageTagCoreInstance, M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStopCommand.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStopCommand.java index a438495f70d..4a38bda0eeb 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStopCommand.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongoDBStopCommand.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.engine.plan.execution.stores.mongodb.test.shared.MongoDBCommands; import org.finos.legend.pure.m3.compiler.Context; @@ -48,7 +49,7 @@ public MongoDBStopCommand(FunctionExecutionInterpreted functionExecution, ModelR } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance imageTagCoreInstance = params.get(0); String imageTag = Instance.getValueForMetaPropertyToOneResolved(imageTagCoreInstance, M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongodBRequestCommand.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongodBRequestCommand.java index 9f63a9dc586..f316afe364c 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongodBRequestCommand.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan-test/src/main/java/org/finos/legend/engine/plan/execution/stores/mongodb/test/interpreted/MongodBRequestCommand.java @@ -17,6 +17,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.finos.legend.engine.plan.execution.stores.mongodb.test.shared.MongoDBCommands; import org.finos.legend.pure.m3.compiler.Context; import org.finos.legend.pure.m3.exception.PureExecutionException; @@ -47,7 +48,7 @@ public MongodBRequestCommand(FunctionExecutionInterpreted functionExecution, Mod } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance imageTagCoreInstance = params.get(0); String imageTag = Instance.getValueForMetaPropertyToOneResolved(imageTagCoreInstance, M3Properties.values, processorSupport).getName(); diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan/pom.xml b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan/pom.xml index 19106d0fb0f..a0a7887a5f2 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan/pom.xml +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-executionPlan/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-mongodb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-nonrelationalStore-mongodb-executionPlan diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/pom.xml b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/pom.xml index 0439936fe43..666406b444e 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/pom.xml +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-mongodb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-nonrelationalStore-mongodb-grammar-integration diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar/pom.xml b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar/pom.xml index dc1792f43ff..81b9e9a8484 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar/pom.xml +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-mongodb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-nonrelationalStore-mongodb-grammar diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-javaPlatformBinding-pure/pom.xml b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-javaPlatformBinding-pure/pom.xml index b4a8a24a4a0..e3f84bb8c6d 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-javaPlatformBinding-pure/pom.xml +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-javaPlatformBinding-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-mongodb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-nonrelationalStore-mongodb-javaPlatformBinding-pure diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-protocol/pom.xml b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-protocol/pom.xml index 5eed2fa503d..6855358f175 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-protocol/pom.xml +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-mongodb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-nonrelationalStore-mongodb-protocol diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-pure/pom.xml b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-pure/pom.xml index 712878b0754..7e78392fbb0 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-pure/pom.xml +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-pure/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-xts-mongodb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-nonrelationalStore-mongodb-pure diff --git a/legend-engine-xts-mongodb/pom.xml b/legend-engine-xts-mongodb/pom.xml index 5a1f2e770f5..0e84b0f8b3f 100644 --- a/legend-engine-xts-mongodb/pom.xml +++ b/legend-engine-xts-mongodb/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-morphir/legend-engine-xt-morphir-http-api/pom.xml b/legend-engine-xts-morphir/legend-engine-xt-morphir-http-api/pom.xml index 03700ed544b..746a5a84ace 100644 --- a/legend-engine-xts-morphir/legend-engine-xt-morphir-http-api/pom.xml +++ b/legend-engine-xts-morphir/legend-engine-xt-morphir-http-api/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-morphir org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-morphir-http-api diff --git a/legend-engine-xts-morphir/legend-engine-xt-morphir-pure/pom.xml b/legend-engine-xts-morphir/legend-engine-xt-morphir-pure/pom.xml index 53def056057..716826898c5 100644 --- a/legend-engine-xts-morphir/legend-engine-xt-morphir-pure/pom.xml +++ b/legend-engine-xts-morphir/legend-engine-xt-morphir-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-morphir - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-morphir/legend-engine-xt-morphir/pom.xml b/legend-engine-xts-morphir/legend-engine-xt-morphir/pom.xml index efeb5e9098f..cf31f81087a 100644 --- a/legend-engine-xts-morphir/legend-engine-xt-morphir/pom.xml +++ b/legend-engine-xts-morphir/legend-engine-xt-morphir/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-morphir org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-morphir/pom.xml b/legend-engine-xts-morphir/pom.xml index 1e144a76eb1..400ae6f2ee0 100644 --- a/legend-engine-xts-morphir/pom.xml +++ b/legend-engine-xts-morphir/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-openapi/legend-engine-xt-openapi-generation/pom.xml b/legend-engine-xts-openapi/legend-engine-xt-openapi-generation/pom.xml index 0f179e20ef4..e58dfa9d8a1 100644 --- a/legend-engine-xts-openapi/legend-engine-xt-openapi-generation/pom.xml +++ b/legend-engine-xts-openapi/legend-engine-xt-openapi-generation/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-xts-openapi - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-openapi-generation diff --git a/legend-engine-xts-openapi/legend-engine-xt-openapi-pure/pom.xml b/legend-engine-xts-openapi/legend-engine-xt-openapi-pure/pom.xml index 1d71e84240a..799b67f7aea 100644 --- a/legend-engine-xts-openapi/legend-engine-xt-openapi-pure/pom.xml +++ b/legend-engine-xts-openapi/legend-engine-xt-openapi-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-openapi - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-openapi-pure diff --git a/legend-engine-xts-openapi/pom.xml b/legend-engine-xts-openapi/pom.xml index 65004594a37..2b7a9d8624e 100644 --- a/legend-engine-xts-openapi/pom.xml +++ b/legend-engine-xts-openapi/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-grammar/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-grammar/pom.xml index 03063af9ea1..bc11a3da163 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-grammar/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-grammar/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-protocol/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-protocol/pom.xml index 8a1b21e41bd..289c4f18700 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-protocol/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-pure/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-pure/pom.xml index c13af44f0a6..27a12a53657 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-pure/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-cloud-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/pom.xml index 7854d6412f3..7510a90e48d 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/OptimizationFilterAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/OptimizationFilterAbstract.java index c4bf45b39e6..9e50bc12d10 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/OptimizationFilterAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/OptimizationFilterAbstract.java @@ -29,11 +29,17 @@ public interface OptimizationFilterAbstract @Value.Parameter(order = 0) String fieldName(); - @Value.Parameter(order = 1) - String lowerBoundPattern(); + @Value.Default + default String lowerBoundPattern() + { + return "{" + fieldName() + "_legend_persistence_lower}"; + } - @Value.Parameter(order = 2) - String upperBoundPattern(); + @Value.Default + default String upperBoundPattern() + { + return "{" + fieldName() + "_legend_persistence_upper}"; + } @Value.Default default boolean includesNullValues() diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/StatisticName.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/StatisticName.java index 23c5aae58e9..7bdfb3ecb3a 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/StatisticName.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/common/StatisticName.java @@ -22,7 +22,8 @@ public enum StatisticName ROWS_UPDATED("rowsUpdated"), ROWS_DELETED("rowsDeleted"), FILES_LOADED("filesLoaded"), - ROWS_WITH_ERRORS("rowsWithErrors"); + ROWS_WITH_ERRORS("rowsWithErrors"), + INPUT_FILES_BYTES_SCANNED("inputFilesBytesScanned"); String value; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/DatasetReferenceImplAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/DatasetReferenceImplAbstract.java index 6ad30972cc6..2c96c932ab0 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/DatasetReferenceImplAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/DatasetReferenceImplAbstract.java @@ -17,6 +17,8 @@ import org.immutables.value.Value.Immutable; import org.immutables.value.Value.Style; +import java.util.Optional; + @Immutable @Style( typeAbstract = "*Abstract", @@ -27,4 +29,5 @@ ) public interface DatasetReferenceImplAbstract extends DatasetReference { + Optional datasetAdditionalProperties(); } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/FunctionalDatasetAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/FunctionalDatasetAbstract.java new file mode 100644 index 00000000000..1d37ee0c33e --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/datasets/FunctionalDatasetAbstract.java @@ -0,0 +1,34 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.logicalplan.datasets; + +import java.util.List; +import org.finos.legend.engine.persistence.components.logicalplan.values.Value; +import org.immutables.value.Value.Immutable; +import org.immutables.value.Value.Style; + +@Immutable +@Style( + typeAbstract = "*Abstract", + typeImmutable = "*", + jdkOnly = true, + optionalAcceptNullable = true, + strictBuilder = true +) +public interface FunctionalDatasetAbstract extends DatasetReference +{ + + List value(); +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/values/FunctionName.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/values/FunctionName.java index 2f3c045d1a1..355a561e397 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/values/FunctionName.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/logicalplan/values/FunctionName.java @@ -45,5 +45,6 @@ public enum FunctionName CONVERT, STRUCT, CONCAT, + JSON_EXTRACT_PATH_TEXT, APPROX_COUNT_DISTINCT; } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/BitemporalDeltaPlanner.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/BitemporalDeltaPlanner.java index 88c65629449..641a08a3e0a 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/BitemporalDeltaPlanner.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/planner/BitemporalDeltaPlanner.java @@ -56,6 +56,7 @@ import org.finos.legend.engine.persistence.components.logicalplan.values.DiffBinaryValueOperator; import org.finos.legend.engine.persistence.components.util.Capability; import org.finos.legend.engine.persistence.components.util.LogicalPlanUtils; +import org.finos.legend.engine.persistence.components.util.TableNameGenUtils; import java.util.ArrayList; import java.util.List; @@ -67,7 +68,6 @@ import static org.finos.legend.engine.persistence.components.common.StatisticName.ROWS_UPDATED; import static org.finos.legend.engine.persistence.components.common.StatisticName.ROWS_TERMINATED; import static org.finos.legend.engine.persistence.components.common.StatisticName.ROWS_INSERTED; -import static org.finos.legend.engine.persistence.components.util.LogicalPlanUtils.UNDERSCORE; class BitemporalDeltaPlanner extends BitemporalPlanner { @@ -110,7 +110,7 @@ class BitemporalDeltaPlanner extends BitemporalPlanner if (ingestMode().validityMilestoning().validityDerivation() instanceof SourceSpecifiesFromDateTime && ingestMode().filterExistingRecords()) { - this.stagingDataset = getStagingDatasetWithoutDuplicates(datasets); + this.stagingDataset = getStagingDatasetWithoutDuplicates(datasets, options().ingestRunId()); this.stagingDatasetWithoutDuplicates = Optional.of(this.stagingDataset); } else @@ -173,22 +173,23 @@ class BitemporalDeltaPlanner extends BitemporalPlanner if (ingestMode().validityMilestoning().validityDerivation() instanceof SourceSpecifiesFromDateTime) { - this.tempDataset = LogicalPlanUtils.getTempDataset(datasets); + this.tempDataset = LogicalPlanUtils.getTempDataset(datasets, options().ingestRunId()); if (deleteIndicatorField.isPresent()) { - this.tempDatasetWithDeleteIndicator = LogicalPlanUtils.getTempDatasetWithDeleteIndicator(datasets, deleteIndicatorField.get()); + this.tempDatasetWithDeleteIndicator = LogicalPlanUtils.getTempDatasetWithDeleteIndicator(datasets, deleteIndicatorField.get(), options().ingestRunId()); } } } - private Dataset getStagingDatasetWithoutDuplicates(Datasets datasets) + private Dataset getStagingDatasetWithoutDuplicates(Datasets datasets, String ingestRunId) { - String tableName = stagingDataset().datasetReference().name().orElseThrow((IllegalStateException::new)); + String stagingTableName = stagingDataset().datasetReference().name().orElseThrow((IllegalStateException::new)); + String tempDatasetName = TableNameGenUtils.generateTableName(stagingTableName, STAGE_DATASET_WITHOUT_DUPLICATES_BASE_NAME, ingestRunId); return datasets.stagingDatasetWithoutDuplicates().orElse(DatasetDefinition.builder() .schema(stagingDataset().schema()) .database(stagingDataset().datasetReference().database()) .group(stagingDataset().datasetReference().group()) - .name(tableName + UNDERSCORE + STAGE_DATASET_WITHOUT_DUPLICATES_BASE_NAME) + .name(tempDatasetName) .alias(STAGE_DATASET_WITHOUT_DUPLICATES_BASE_NAME) .build()); } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java index a6880891760..85f19b2ac33 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-logical-plan/src/main/java/org/finos/legend/engine/persistence/components/util/LogicalPlanUtils.java @@ -441,19 +441,20 @@ public static StagedFilesFieldValue getStagedFilesFieldValueWithType(Dataset dat .build(); } - public static Dataset getTempDataset(Datasets datasets) + public static Dataset getTempDataset(Datasets datasets, String ingestRunId) { String mainDatasetName = datasets.mainDataset().datasetReference().name().orElseThrow((IllegalStateException::new)); + String tempDatasetName = TableNameGenUtils.generateTableName(mainDatasetName, TEMP_DATASET_BASE_NAME, ingestRunId); return datasets.tempDataset().orElse(DatasetDefinition.builder() .schema(datasets.mainDataset().schema()) .database(datasets.mainDataset().datasetReference().database()) .group(datasets.mainDataset().datasetReference().group()) - .name(mainDatasetName + UNDERSCORE + TEMP_DATASET_BASE_NAME) + .name(tempDatasetName) .alias(TEMP_DATASET_BASE_NAME) .build()); } - public static Dataset getTempDatasetWithDeleteIndicator(Datasets datasets, String deleteIndicatorField) + public static Dataset getTempDatasetWithDeleteIndicator(Datasets datasets, String deleteIndicatorField, String ingestRunId) { if (datasets.tempDatasetWithDeleteIndicator().isPresent()) { @@ -462,6 +463,7 @@ public static Dataset getTempDatasetWithDeleteIndicator(Datasets datasets, Strin else { String mainDatasetName = datasets.mainDataset().datasetReference().name().orElseThrow((IllegalStateException::new)); + String tempDatasetName = TableNameGenUtils.generateTableName(mainDatasetName, TEMP_DATASET_WITH_DELETE_INDICATOR_BASE_NAME, ingestRunId); Field deleteIndicator = Field.builder().name(deleteIndicatorField).type(FieldType.of(DataType.BOOLEAN, Optional.empty(), Optional.empty())).build(); List mainFieldsPlusDeleteIndicator = new ArrayList<>(datasets.mainDataset().schema().fields()); mainFieldsPlusDeleteIndicator.add(deleteIndicator); @@ -469,7 +471,7 @@ public static Dataset getTempDatasetWithDeleteIndicator(Datasets datasets, Strin .schema(datasets.mainDataset().schema().withFields(mainFieldsPlusDeleteIndicator)) .database(datasets.mainDataset().datasetReference().database()) .group(datasets.mainDataset().datasetReference().group()) - .name(mainDatasetName + UNDERSCORE + TEMP_DATASET_WITH_DELETE_INDICATOR_BASE_NAME) + .name(tempDatasetName) .alias(TEMP_DATASET_WITH_DELETE_INDICATOR_BASE_NAME) .build(); } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/pom.xml index af09caa15d5..8a1dde81500 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/RelationalExecutionHelper.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/RelationalExecutionHelper.java index 9ea0ce65b47..84316e21d15 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/RelationalExecutionHelper.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/RelationalExecutionHelper.java @@ -46,5 +46,9 @@ public interface RelationalExecutionHelper List> executeQuery(String sql); + TabularData executeQueryAndGetResultsAsTabularData(String sql); + + TabularData executeQueryAndGetResultsAsTabularData(String sql, int rows); + void close(); } \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/RelationalTransactionManager.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/RelationalTransactionManager.java new file mode 100644 index 00000000000..9089ca332b3 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/RelationalTransactionManager.java @@ -0,0 +1,50 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.executor; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; + +public interface RelationalTransactionManager +{ + void close() throws SQLException; + + void beginTransaction() throws SQLException; + + void commitTransaction() throws SQLException; + + void revertTransaction() throws SQLException; + + boolean executeInCurrentTransaction(String sql) throws SQLException; + + List> convertResultSetToList(String sql) throws SQLException; + + List> convertResultSetToList(String sql, int rows) throws SQLException; + + default TabularData convertResultSetToTabularData(String sql) throws SQLException + { + return TabularData.builder() + .addAllData(convertResultSetToList(sql)) + .build(); + } + + default TabularData convertResultSetToTabularData(String sql, int rows) throws SQLException + { + return TabularData.builder() + .addAllData(convertResultSetToList(sql, rows)) + .build(); + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sql/TabularData.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/TabularDataAbstract.java similarity index 56% rename from legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sql/TabularData.java rename to legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/TabularDataAbstract.java index 0442e87922a..ba550c2d704 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sql/TabularData.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-physical-plan/src/main/java/org/finos/legend/engine/persistence/components/executor/TabularDataAbstract.java @@ -12,26 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -package org.finos.legend.engine.persistence.components.relational.sql; - -import org.finos.legend.engine.persistence.components.executor.ResultData; +package org.finos.legend.engine.persistence.components.executor; import java.util.List; import java.util.Map; +import java.util.Optional; -public class TabularData implements ResultData -{ - private final List> data; - - public TabularData(List> data) - { - this.data = data; - } +import static org.immutables.value.Value.Immutable; +import static org.immutables.value.Value.Style; - public List> getData() - { - return data; - } +@Immutable +@Style( + typeAbstract = "*Abstract", + typeImmutable = "*", + jdkOnly = true, + optionalAcceptNullable = true, + strictBuilder = true +) +public interface TabularDataAbstract extends ResultData +{ + Optional queryId(); - // todo: Add a field for schema -} + List> data(); +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/pom.xml index 91f94424a55..f58e74d0e92 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/pom.xml @@ -15,7 +15,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/main/java/org/finos/legend/engine/persistence/components/relational/ansi/AnsiSqlSink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/main/java/org/finos/legend/engine/persistence/components/relational/ansi/AnsiSqlSink.java index 332c6700ae8..634f7f89325 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/main/java/org/finos/legend/engine/persistence/components/relational/ansi/AnsiSqlSink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/main/java/org/finos/legend/engine/persistence/components/relational/ansi/AnsiSqlSink.java @@ -156,7 +156,7 @@ import org.finos.legend.engine.persistence.components.relational.api.ErrorCategory; import org.finos.legend.engine.persistence.components.relational.api.IngestorResult; import org.finos.legend.engine.persistence.components.relational.api.RelationalConnection; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils; import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; @@ -393,7 +393,7 @@ protected int findNullValuesDataErrors(Executor ex List results = executor.executePhysicalPlanAndGetResults(pair.getTwo()); if (!results.isEmpty()) { - List> resultSets = results.get(0).getData(); + List> resultSets = results.get(0).data(); for (Map row : resultSets) { for (String column : pair.getOne().stream().map(FieldValue::fieldName).collect(Collectors.toSet())) diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTest.java index 5052869bbda..91ba7402c6c 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTest.java @@ -322,8 +322,8 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndNoDataSplits(Generator @Override public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplits(List operations, List dataSplitRanges) { - String tempName = operations.get(0).preActionsSql().get(2).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String tempWithDeleteIndicatorName = operations.get(0).preActionsSql().get(3).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; + String tempName = "\"mydb\".\"main_legend_persistence_temp_lp_yosulf\""; + String tempWithDeleteIndicatorName = "\"mydb\".\"main_legend_persistence_tempWithDeleteIndicator_lp_yosulf\""; String expectedBitemporalFromOnlyDefaultTempTableCreateQuery = "CREATE TABLE IF NOT EXISTS " + tempName + "(\"id\" INTEGER NOT NULL," + @@ -786,9 +786,9 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndNoDataSplitsFilterDupl @Override public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDuplicates(List operations, List dataSplitRanges) { - String tempName = operations.get(0).preActionsSql().get(2).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String tempWithDeleteIndicatorName = operations.get(0).preActionsSql().get(3).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String stageWithoutDuplicatesName = operations.get(0).preActionsSql().get(4).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; + String tempName = "\"mydb\".\"main_legend_persistence_temp_lp_yosulf\""; + String tempWithDeleteIndicatorName = "\"mydb\".\"main_legend_persistence_tempWithDeleteIndicator_lp_yosulf\""; + String stageWithoutDuplicatesName = "\"mydb\".\"staging_legend_persistence_stageWithoutDuplicates_lp_yosulf\""; String expectedBitemporalFromOnlyDefaultTempTableCreateQuery = "CREATE TABLE IF NOT EXISTS " + tempName + "(\"id\" INTEGER NOT NULL," + @@ -950,9 +950,9 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDu Assertions.assertEquals(getExpectedMetadataTableIngestQuery(), operations.get(0).metadataIngestSql().get(0)); - Assertions.assertEquals(getDropTempTableQuery("\"mydb\".\"main_legend_persistence_temp\""), operations.get(0).postCleanupSql().get(0)); - Assertions.assertEquals(getDropTempTableQuery("\"mydb\".\"main_legend_persistence_tempWithDeleteIndicator\""), operations.get(0).postCleanupSql().get(1)); - Assertions.assertEquals(getDropTempTableQuery("\"mydb\".\"staging_legend_persistence_stageWithoutDuplicates\""), operations.get(0).postCleanupSql().get(2)); + Assertions.assertEquals(getDropTempTableQuery(tempName), operations.get(0).postCleanupSql().get(0)); + Assertions.assertEquals(getDropTempTableQuery(tempWithDeleteIndicatorName), operations.get(0).postCleanupSql().get(1)); + Assertions.assertEquals(getDropTempTableQuery(stageWithoutDuplicatesName), operations.get(0).postCleanupSql().get(2)); Assertions.assertEquals(2, operations.size()); String incomingRecordCount = "SELECT COUNT(*) as \"incomingRecordCount\" FROM \"mydb\".\"staging\" as stage WHERE (stage.\"data_split\" >= '{DATA_SPLIT_LOWER_BOUND_PLACEHOLDER}') AND (stage.\"data_split\" <= '{DATA_SPLIT_UPPER_BOUND_PLACEHOLDER}')"; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaBatchIdBasedTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaBatchIdBasedTest.java index 2bf136eb916..44be2b10179 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaBatchIdBasedTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-ansi/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaBatchIdBasedTest.java @@ -550,7 +550,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe String expectedMilestoneQuery = "UPDATE \"mydb\".\"main\" as sink " + "SET sink.\"batch_id_out\" = (SELECT COALESCE(MAX(batch_metadata.\"table_batch_id\"),0)+1 FROM batch_metadata as batch_metadata WHERE UPPER(batch_metadata.\"table_name\") = 'MAIN')-1 " + - "WHERE (sink.\"batch_id_out\" = 999999999) AND ((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')) AND " + + "WHERE (sink.\"batch_id_out\" = 999999999) AND ((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')) AND " + "(EXISTS (SELECT * FROM \"mydb\".\"staging\" as stage " + "WHERE ((sink.\"id\" = stage.\"id\") AND (sink.\"name\" = stage.\"name\")) AND " + "(sink.\"digest\" <> stage.\"digest\")))"; @@ -564,7 +564,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe "WHERE NOT (EXISTS " + "(SELECT * FROM \"mydb\".\"main\" as sink WHERE (sink.\"batch_id_out\" = 999999999) AND " + "(sink.\"digest\" = stage.\"digest\") AND ((sink.\"id\" = stage.\"id\") AND (sink.\"name\" = stage.\"name\")) " + - "AND ((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')))))"; + "AND ((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')))))"; Assertions.assertEquals(AnsiTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(getExpectedMetadataTableCreateQuery(), preActionsSql.get(1)); @@ -591,7 +591,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull String expectedMilestoneQuery = "UPDATE \"mydb\".\"main\" as sink " + "SET sink.\"batch_id_out\" = (SELECT COALESCE(MAX(batch_metadata.\"table_batch_id\"),0)+1 FROM batch_metadata as batch_metadata WHERE UPPER(batch_metadata.\"table_name\") = 'MAIN')-1 " + - "WHERE (sink.\"batch_id_out\" = 999999999) AND (((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')) OR (sink.\"id\" IS NULL)) AND " + + "WHERE (sink.\"batch_id_out\" = 999999999) AND (((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')) OR (sink.\"id\" IS NULL)) AND " + "(EXISTS (SELECT * FROM \"mydb\".\"staging\" as stage " + "WHERE ((sink.\"id\" = stage.\"id\") AND (sink.\"name\" = stage.\"name\")) AND " + "(sink.\"digest\" <> stage.\"digest\")))"; @@ -605,7 +605,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull "WHERE NOT (EXISTS " + "(SELECT * FROM \"mydb\".\"main\" as sink WHERE (sink.\"batch_id_out\" = 999999999) AND " + "(sink.\"digest\" = stage.\"digest\") AND ((sink.\"id\" = stage.\"id\") AND (sink.\"name\" = stage.\"name\")) " + - "AND (((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')) OR (sink.\"id\" IS NULL)))))"; + "AND (((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')) OR (sink.\"id\" IS NULL)))))"; Assertions.assertEquals(AnsiTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(getExpectedMetadataTableCreateQuery(), preActionsSql.get(1)); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/pom.xml index 3eee02134f4..6e8d4d98143 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/BigQuerySink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/BigQuerySink.java index 68b16ae055c..f9043683a09 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/BigQuerySink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/BigQuerySink.java @@ -70,7 +70,7 @@ import org.finos.legend.engine.persistence.components.relational.bigquery.sql.visitor.StagedFilesSelectionVisitor; import org.finos.legend.engine.persistence.components.relational.bigquery.sql.visitor.ToArrayFunctionVisitor; import org.finos.legend.engine.persistence.components.relational.bigquery.sql.visitor.TruncateVisitor; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils; import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java index e11e871cb9d..7eaa2ae8b13 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryExecutor.java @@ -20,7 +20,7 @@ import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset; import org.finos.legend.engine.persistence.components.relational.SqlPlan; import org.finos.legend.engine.persistence.components.relational.bigquery.BigQuerySink; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.statements.DDLStatement; import org.finos.legend.engine.persistence.components.util.PlaceholderValue; @@ -110,7 +110,7 @@ public List executePhysicalPlanAndGetResults(SqlPlan physicalPlan, List> queryResult = bigQueryHelper.executeQuery(enrichedSql); if (!queryResult.isEmpty()) { - resultSetList.add(new TabularData(queryResult)); + resultSetList.add(TabularData.builder().addAllData(queryResult).build()); } } return resultSetList; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java index 863fd1d2089..1f17c18eb2c 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/main/java/org/finos/legend/engine/persistence/components/relational/bigquery/executor/BigQueryHelper.java @@ -18,6 +18,7 @@ import com.google.cloud.bigquery.FieldList; import com.google.cloud.bigquery.TableId; import org.finos.legend.engine.persistence.components.common.StatisticName; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.executor.TypeMapping; import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlan; import org.finos.legend.engine.persistence.components.logicalplan.conditions.And; @@ -454,6 +455,22 @@ public List> executeQuery(String sql) } } + @Override + public TabularData executeQueryAndGetResultsAsTabularData(String sql) + { + return TabularData.builder() + .addAllData(executeQuery(sql)) + .build(); + } + + @Override + public TabularData executeQueryAndGetResultsAsTabularData(String sql, int rows) + { + return TabularData.builder() + .addAllData(executeQuery(sql, rows)) + .build(); + } + // Execute statement in a transaction - either use an existing one or use a new one public Map executeLoadStatement(String sql) { diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/e2e/SchemaEvolutionTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/e2e/SchemaEvolutionTest.java index a0853dde352..54e56551a49 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/e2e/SchemaEvolutionTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/e2e/SchemaEvolutionTest.java @@ -36,7 +36,7 @@ import org.finos.legend.engine.persistence.components.relational.bigquery.BigQuerySink; import org.finos.legend.engine.persistence.components.relational.bigquery.executor.BigQueryConnection; import org.finos.legend.engine.persistence.components.relational.bigquery.executor.BigQueryHelper; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.finos.legend.engine.persistence.components.schemaevolution.IncompatibleSchemaChangeException; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java index 2a3b8dc9ad7..0e5bc1c5c37 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java @@ -310,8 +310,8 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndNoDataSplits(Generator @Override public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplits(List operations, List dataSplitRanges) { - String tempName = operations.get(0).preActionsSql().get(2).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String tempWithDeleteIndicatorName = operations.get(0).preActionsSql().get(3).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; + String tempName = "`mydb`.`main_legend_persistence_temp_lp_yosulf`"; + String tempWithDeleteIndicatorName = "`mydb`.`main_legend_persistence_tempWithDeleteIndicator_lp_yosulf`"; String expectedBitemporalFromOnlyDefaultTempTableCreateQuery = "CREATE TABLE IF NOT EXISTS " + tempName + "(`id` INT64 NOT NULL," + @@ -766,9 +766,9 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndNoDataSplitsFilterDupl @Override public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDuplicates(List operations, List dataSplitRanges) { - String tempName = operations.get(0).preActionsSql().get(2).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String tempWithDeleteIndicatorName = operations.get(0).preActionsSql().get(3).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String stageWithoutDuplicatesName = operations.get(0).preActionsSql().get(4).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; + String tempName = "`mydb`.`main_legend_persistence_temp_lp_yosulf`"; + String tempWithDeleteIndicatorName = "`mydb`.`main_legend_persistence_tempWithDeleteIndicator_lp_yosulf`"; + String stageWithoutDuplicatesName = "`mydb`.`staging_legend_persistence_stageWithoutDuplicates_lp_yosulf`"; String expectedBitemporalFromOnlyDefaultTempTableCreateQuery = "CREATE TABLE IF NOT EXISTS " + tempName + "(`id` INT64 NOT NULL," + @@ -930,9 +930,9 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDu Assertions.assertEquals(getExpectedMetadataTableIngestQuery(), operations.get(0).metadataIngestSql().get(0)); - Assertions.assertEquals(getDropTempTableQuery("`mydb`.`main_legend_persistence_temp`"), operations.get(0).postCleanupSql().get(0)); - Assertions.assertEquals(getDropTempTableQuery("`mydb`.`main_legend_persistence_tempWithDeleteIndicator`"), operations.get(0).postCleanupSql().get(1)); - Assertions.assertEquals(getDropTempTableQuery("`mydb`.`staging_legend_persistence_stageWithoutDuplicates`"), operations.get(0).postCleanupSql().get(2)); + Assertions.assertEquals(getDropTempTableQuery(tempName), operations.get(0).postCleanupSql().get(0)); + Assertions.assertEquals(getDropTempTableQuery(tempWithDeleteIndicatorName), operations.get(0).postCleanupSql().get(1)); + Assertions.assertEquals(getDropTempTableQuery(stageWithoutDuplicatesName), operations.get(0).postCleanupSql().get(2)); Assertions.assertEquals(2, operations.size()); String incomingRecordCount = "SELECT COUNT(*) as `incomingRecordCount` FROM `mydb`.`staging` as stage WHERE (stage.`data_split` >= '{DATA_SPLIT_LOWER_BOUND_PLACEHOLDER}') AND (stage.`data_split` <= '{DATA_SPLIT_UPPER_BOUND_PLACEHOLDER}')"; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java index 1a7125c4d58..418d72723dd 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-bigquery/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java @@ -239,7 +239,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe String expectedMilestoneQuery = "UPDATE `mydb`.`main` as sink " + "SET sink.`batch_id_out` = (SELECT COALESCE(MAX(batch_metadata.`table_batch_id`),0)+1 FROM batch_metadata as batch_metadata " + "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN')-1 WHERE " + - "(sink.`batch_id_out` = 999999999) AND ((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')) " + + "(sink.`batch_id_out` = 999999999) AND ((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')) " + "AND (EXISTS (SELECT * FROM `mydb`.`staging` as stage WHERE ((sink.`id` = stage.`id`) " + "AND (sink.`name` = stage.`name`)) AND (sink.`digest` <> stage.`digest`)))"; @@ -250,7 +250,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN'),999999999 FROM `mydb`.`staging` as stage " + "WHERE NOT (EXISTS (SELECT * FROM `mydb`.`main` as sink WHERE (sink.`batch_id_out` = 999999999) AND " + "(sink.`digest` = stage.`digest`) AND ((sink.`id` = stage.`id`) AND (sink.`name` = stage.`name`)) AND " + - "((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')))))"; + "((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')))))"; Assertions.assertEquals(BigQueryTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(BigQueryTestArtifacts.expectedMetadataTableCreateQuery, preActionsSql.get(1)); @@ -270,7 +270,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull String expectedMilestoneQuery = "UPDATE `mydb`.`main` as sink " + "SET sink.`batch_id_out` = (SELECT COALESCE(MAX(batch_metadata.`table_batch_id`),0)+1 FROM batch_metadata as batch_metadata " + "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN')-1 WHERE " + - "(sink.`batch_id_out` = 999999999) AND (((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')) OR (sink.`id` IS NULL)) " + + "(sink.`batch_id_out` = 999999999) AND (((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')) OR (sink.`id` IS NULL)) " + "AND (EXISTS (SELECT * FROM `mydb`.`staging` as stage WHERE ((sink.`id` = stage.`id`) " + "AND (sink.`name` = stage.`name`)) AND (sink.`digest` <> stage.`digest`)))"; @@ -281,7 +281,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN'),999999999 FROM `mydb`.`staging` as stage " + "WHERE NOT (EXISTS (SELECT * FROM `mydb`.`main` as sink WHERE (sink.`batch_id_out` = 999999999) AND " + "(sink.`digest` = stage.`digest`) AND ((sink.`id` = stage.`id`) AND (sink.`name` = stage.`name`)) AND " + - "(((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')) OR (sink.`id` IS NULL)))))"; + "(((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')) OR (sink.`id` IS NULL)))))"; Assertions.assertEquals(BigQueryTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(BigQueryTestArtifacts.expectedMetadataTableCreateQuery, preActionsSql.get(1)); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/pom.xml index 71e11f5208a..5d9d9d7c161 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/RelationalSink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/RelationalSink.java index 4ff671b071f..4f21931e3e8 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/RelationalSink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/RelationalSink.java @@ -18,6 +18,7 @@ import org.finos.legend.engine.persistence.components.common.Datasets; import org.finos.legend.engine.persistence.components.common.StatisticName; import org.finos.legend.engine.persistence.components.executor.Executor; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.ingestmode.AppendOnlyAbstract; import org.finos.legend.engine.persistence.components.ingestmode.BitemporalDeltaAbstract; import org.finos.legend.engine.persistence.components.ingestmode.BitemporalSnapshotAbstract; @@ -40,7 +41,7 @@ import org.finos.legend.engine.persistence.components.relational.api.IngestorResult; import org.finos.legend.engine.persistence.components.relational.api.RelationalConnection; import org.finos.legend.engine.persistence.components.executor.RelationalExecutionHelper; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.sink.Sink; import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/IngestModeOptimizer.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/IngestModeOptimizer.java index 3473e0eef2d..182c6ddfb2b 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/IngestModeOptimizer.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/IngestModeOptimizer.java @@ -22,7 +22,7 @@ import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanFactory; import org.finos.legend.engine.persistence.components.logicalplan.datasets.Field; import org.finos.legend.engine.persistence.components.relational.SqlPlan; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.transformer.Transformer; @@ -146,7 +146,7 @@ private List> derivePartitionSpecList(List partition if (!partitionSpecResult.isEmpty()) { - List> partitionSpecRows = partitionSpecResult.get(0).getData(); + List> partitionSpecRows = partitionSpecResult.get(0).data(); for (Map partitionSpec: partitionSpecRows) { partitionSpecList.add(partitionSpec); @@ -159,17 +159,13 @@ private List> derivePartitionSpecList(List partition private List deriveOptimizationFilters(UnitemporalDeltaAbstract unitemporalDelta) { - List optimizationFilters = unitemporalDelta.optimizationFilters(); - if (optimizationFilters == null || optimizationFilters.isEmpty()) + List optimizationFilters = new ArrayList<>(); + List primaryKeys = findCommonPrimaryFieldsBetweenMainAndStaging(datasets.mainDataset(), datasets.stagingDataset()); + List comparablePrimaryKeys = primaryKeys.stream().filter(field -> SUPPORTED_DATA_TYPES_FOR_OPTIMIZATION_COLUMNS.contains(field.type().dataType())).collect(Collectors.toList()); + for (Field field : comparablePrimaryKeys) { - List primaryKeys = findCommonPrimaryFieldsBetweenMainAndStaging(datasets.mainDataset(), datasets.stagingDataset()); - List comparablePrimaryKeys = primaryKeys.stream().filter(field -> SUPPORTED_DATA_TYPES_FOR_OPTIMIZATION_COLUMNS.contains(field.type().dataType())).collect(Collectors.toList()); - optimizationFilters = new ArrayList<>(); - for (Field field : comparablePrimaryKeys) - { - OptimizationFilter filter = OptimizationFilter.of(field.name(), field.name().toUpperCase() + "_LOWER", field.name().toUpperCase() + "_UPPER"); - optimizationFilters.add(filter); - } + OptimizationFilter filter = OptimizationFilter.of(field.name()); + optimizationFilters.add(filter); } return optimizationFilters; } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalGeneratorAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalGeneratorAbstract.java index 1ee92ed47da..d3c4ae721b6 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalGeneratorAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalGeneratorAbstract.java @@ -406,11 +406,20 @@ GeneratorResult generateOperationsForCreate(Planner planner) LogicalPlan preActionsLogicalPlan = planner.buildLogicalPlanForPreActions(); SqlPlan preActionsSqlPlan = transformer.generatePhysicalPlan(preActionsLogicalPlan); + // initialize-lock + LogicalPlan initializeLockLogicalPlan = planner.buildLogicalPlanForInitializeLock(Resources.builder().build()); + Optional initializeLockSqlPlan = Optional.empty(); + if (initializeLockLogicalPlan != null) + { + initializeLockSqlPlan = Optional.of(transformer.generatePhysicalPlan(initializeLockLogicalPlan)); + } + return GeneratorResult.builder() .preActionsSqlPlan(preActionsSqlPlan) .ingestSqlPlan(SqlPlan.builder().build()) .metadataIngestSqlPlan(SqlPlan.builder().build()) .postActionsSqlPlan(SqlPlan.builder().build()) + .initializeLockSqlPlan(initializeLockSqlPlan) .build(); } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalIngestorAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalIngestorAbstract.java index 3066fd45bcb..d393d22de3c 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalIngestorAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalIngestorAbstract.java @@ -32,7 +32,7 @@ import org.finos.legend.engine.persistence.components.relational.SqlPlan; import org.finos.legend.engine.persistence.components.relational.api.utils.ApiUtils; import org.finos.legend.engine.persistence.components.relational.api.utils.IngestionUtils; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.finos.legend.engine.persistence.components.schemaevolution.SchemaEvolution; @@ -282,6 +282,14 @@ public void create() initializeLock(); } + public void create(Datasets datasets) + { + LOGGER.info("Invoked create(datasets) method, will initialize and create the datasets"); + enrichDatasetsAndGenerateOperationsForCreate(datasets); + createAllDatasets(); + initializeLock(); + } + /* - Evolve Schema of Target table based on schema changes in staging table */ @@ -586,14 +594,78 @@ private List performFullIngestion(RelationalConnection connectio finally { executor.close(); + // post Cleanup + postCleanup(); } - // post Cleanup - postCleanup(); LOGGER.info("Ingestion completed"); return result; } + private Datasets enrichDatasetsAndGenerateOperationsForCreate(Datasets datasets) + { + LOGGER.info("Initializing Datasets for create()"); + + // Validation: init(Connection) must have been invoked + if (this.executor == null) + { + throw new IllegalStateException("Executor not initialized, call init(Connection) before invoking this method!"); + } + + // 1. Case handling + enrichedIngestMode = ApiUtils.applyCase(ingestMode(), caseConversion()); + enrichedDatasets = ApiUtils.enrichAndApplyCase(datasets, caseConversion(), enableConcurrentSafety()); + + // 2. Initialize transformer + transformer = new RelationalTransformer(relationalSink(), transformOptions()); + resourcesBuilder = Resources.builder(); + + // 3. Derive main dataset schema + if (enableSchemaEvolution()) + { + if (executor.datasetExists(enrichedDatasets.mainDataset())) + { + enrichedDatasets = enrichedDatasets.withMainDataset(executor.constructDatasetFromDatabase(enrichedDatasets.mainDataset())); + mainDatasetExists = true; + } + else + { + enrichedDatasets = enrichedDatasets.withMainDataset(ApiUtils.deriveMainDatasetFromStaging(enrichedDatasets.mainDataset(), enrichedDatasets.stagingDataset(), enrichedIngestMode)); + } + } + else + { + enrichedDatasets = enrichedDatasets.withMainDataset(ApiUtils.deriveMainDatasetFromStaging(enrichedDatasets.mainDataset(), enrichedDatasets.stagingDataset(), enrichedIngestMode)); + } + + // 4. generate sql plans + RelationalGenerator generator = RelationalGenerator.builder() + .ingestMode(enrichedIngestMode) + .relationalSink(relationalSink()) + .cleanupStagingData(cleanupStagingData()) + .collectStatistics(collectStatistics()) + .writeStatistics(writeStatistics()) + .skipMainAndMetadataDatasetCreation(skipMainAndMetadataDatasetCreation()) + .enableSchemaEvolution(enableSchemaEvolution()) + .addAllSchemaEvolutionCapabilitySet(schemaEvolutionCapabilitySet()) + .ignoreCaseForSchemaEvolution(ignoreCaseForSchemaEvolution()) + .enableConcurrentSafety(enableConcurrentSafety()) + .caseConversion(caseConversion()) + .executionTimestampClock(executionTimestampClock()) + .batchStartTimestampPattern(BATCH_START_TS_PATTERN) + .batchEndTimestampPattern(BATCH_END_TS_PATTERN) + .batchIdPattern(BATCH_ID_PATTERN) + .ingestRequestId(ingestRequestId()) + .batchSuccessStatusValue(batchSuccessStatusValue()) + .sampleRowCount(sampleRowCount()) + .ingestRunId(getRunId()) + .build(); + + planner = Planners.get(enrichedDatasets, enrichedIngestMode, generator.plannerOptions(), relationalSink().capabilities()); + generatorResult = generator.generateOperationsForCreate(planner); + + return enrichedDatasets; + } private Datasets enrichDatasetsAndGenerateOperations(Datasets datasets) { @@ -626,11 +698,18 @@ private Datasets enrichDatasetsAndGenerateOperations(Datasets datasets) resourcesBuilder.stagingDataSetEmpty(isStagingDatasetEmpty); } - // 5. Check if main Dataset Exists - mainDatasetExists = executor.datasetExists(enrichedDatasets.mainDataset()); - if (mainDatasetExists && enableSchemaEvolution()) + // 5. Derive main dataset schema + if (enableSchemaEvolution()) { - enrichedDatasets = enrichedDatasets.withMainDataset(executor.constructDatasetFromDatabase(enrichedDatasets.mainDataset())); + if (executor.datasetExists(enrichedDatasets.mainDataset())) + { + enrichedDatasets = enrichedDatasets.withMainDataset(executor.constructDatasetFromDatabase(enrichedDatasets.mainDataset())); + mainDatasetExists = true; + } + else + { + enrichedDatasets = enrichedDatasets.withMainDataset(ApiUtils.deriveMainDatasetFromStaging(enrichedDatasets.mainDataset(), enrichedDatasets.stagingDataset(), enrichedIngestMode)); + } } else { diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalLockProviderAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalLockProviderAbstract.java index 4692598b926..fd88783c396 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalLockProviderAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalLockProviderAbstract.java @@ -23,7 +23,7 @@ import org.finos.legend.engine.persistence.components.relational.RelationalSink; import org.finos.legend.engine.persistence.components.relational.SqlPlan; import org.finos.legend.engine.persistence.components.relational.api.utils.ApiUtils; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.finos.legend.engine.persistence.components.transformer.TransformOptions; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalMultiDatasetIngestorAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalMultiDatasetIngestorAbstract.java index 5a8d319959b..8468901bd9f 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalMultiDatasetIngestorAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalMultiDatasetIngestorAbstract.java @@ -20,6 +20,7 @@ import org.finos.legend.engine.persistence.components.common.Resources; import org.finos.legend.engine.persistence.components.common.StatisticName; import org.finos.legend.engine.persistence.components.executor.Executor; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.ingestmode.BulkLoad; import org.finos.legend.engine.persistence.components.ingestmode.IngestMode; import org.finos.legend.engine.persistence.components.ingestmode.IngestModeVisitors; @@ -41,7 +42,7 @@ import org.finos.legend.engine.persistence.components.relational.api.utils.IngestionUtils; import org.finos.legend.engine.persistence.components.relational.exception.BulkLoadException; import org.finos.legend.engine.persistence.components.relational.exception.MultiDatasetException; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.finos.legend.engine.persistence.components.transformer.TransformOptions; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSchemaEvolutionServiceAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSchemaEvolutionServiceAbstract.java index 0d2e90cff38..31d04632a48 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSchemaEvolutionServiceAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSchemaEvolutionServiceAbstract.java @@ -25,8 +25,7 @@ import org.finos.legend.engine.persistence.components.relational.RelationalSink; import org.finos.legend.engine.persistence.components.relational.SqlPlan; import org.finos.legend.engine.persistence.components.relational.api.utils.ApiUtils; -import org.finos.legend.engine.persistence.components.relational.api.utils.IngestionUtils; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.finos.legend.engine.persistence.components.schemaevolution.SchemaEvolution; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSinkCleanerAbstract.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSinkCleanerAbstract.java index 27aedcd74f6..25a26a51b1b 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSinkCleanerAbstract.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/RelationalSinkCleanerAbstract.java @@ -20,7 +20,7 @@ import org.finos.legend.engine.persistence.components.logicalplan.operations.*; import org.finos.legend.engine.persistence.components.relational.RelationalSink; import org.finos.legend.engine.persistence.components.relational.SqlPlan; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.finos.legend.engine.persistence.components.transformer.TransformOptions; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/utils/IngestionUtils.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/utils/IngestionUtils.java index 5b2c72a0ba3..47da2c5cfd4 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/utils/IngestionUtils.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/api/utils/IngestionUtils.java @@ -43,7 +43,7 @@ import org.finos.legend.engine.persistence.components.relational.api.*; import org.finos.legend.engine.persistence.components.relational.exception.DataQualityException; import org.finos.legend.engine.persistence.components.exception.JsonReadOrWriteException; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.transformer.Transformer; import org.finos.legend.engine.persistence.components.util.LogicalPlanUtils; @@ -105,7 +105,7 @@ public static List verifyIfRequestAlreadyProcessedPreviously(Sch MetadataDataset metadataDataset = enrichedDatasets.metadataDataset().get(); if (!tabularDataList.isEmpty()) { - List> metadataResults = tabularDataList.get(0).getData(); + List> metadataResults = tabularDataList.get(0).data(); for (Map metadata: metadataResults) { Timestamp ingestionTimestampUTC = (Timestamp) metadata.get(metadataDataset.batchStartTimeField()); @@ -147,8 +147,8 @@ public static List performDryRun(IngestMode enrichedIngestMode, Datas } public static List performIngestion(Datasets datasets, Transformer transformer, Planner planner, Executor executor, GeneratorResult generatorResult, List dataSplitRanges, IngestMode ingestMode, - SchemaEvolutionResult schemaEvolutionResult, Map additionalMetadata, Clock executionTimestampClock, Optional batchId) + TabularData, SqlPlan> executor, GeneratorResult generatorResult, List dataSplitRanges, IngestMode ingestMode, + SchemaEvolutionResult schemaEvolutionResult, Map additionalMetadata, Clock executionTimestampClock, Optional batchId) { List results = new ArrayList<>(); int dataSplitIndex = 0; @@ -213,10 +213,10 @@ private static Map executeStatisticsPhysicalPlan(Executor } public static List performBulkLoad(Datasets datasets, Transformer transformer, Planner planner, - Executor executor, GeneratorResult generatorResult, - IngestMode ingestMode, SchemaEvolutionResult schemaEvolutionResult, - Map additionalMetadata, Clock executionTimestampClock, - RelationalSink relationalSink, Optional batchId) + Executor executor, GeneratorResult generatorResult, + IngestMode ingestMode, SchemaEvolutionResult schemaEvolutionResult, + Map additionalMetadata, Clock executionTimestampClock, + RelationalSink relationalSink, Optional batchId) { List results = new ArrayList<>(); Map placeHolderKeyValues = extractPlaceHolderKeyValues(datasets, executor, planner, transformer, ingestMode, Optional.empty(), additionalMetadata, executionTimestampClock, batchId); @@ -364,7 +364,7 @@ public static List extractDatasetFilters(MetadataDataset metadata List results = executor.executePhysicalPlanAndGetResults(physicalPlan); Optional stagingFilters = results.stream() .findFirst() - .map(TabularData::getData) + .map(TabularData::data) .flatMap(t -> t.stream().findFirst()) .map(stringObjectMap -> String.valueOf(stringObjectMap.get(metadataDataset.batchSourceInfoField()))); @@ -432,7 +432,7 @@ public static void dedupAndVersion(Executor execut TabularData duplicateRows = executor.executePhysicalPlanAndGetResults(dedupAndVersionErrorSqlTypeSqlPlanMap.get(DUPLICATE_ROWS), placeHolderKeyValues).get(0); String errorMessage = "Encountered Duplicates, Failing the batch as Fail on Duplicates is set as Deduplication strategy"; LOGGER.error(errorMessage); - List dataErrors = constructDataQualityErrors(enrichedDatasets.stagingDataset(), duplicateRows.getData(), + List dataErrors = constructDataQualityErrors(enrichedDatasets.stagingDataset(), duplicateRows.data(), ErrorCategory.DUPLICATES, caseConversion, DatasetDeduplicationHandler.COUNT, NUM_DUPLICATES); throw new DataQualityException(errorMessage, dataErrors); } @@ -450,7 +450,7 @@ public static void dedupAndVersion(Executor execut TabularData duplicatePkRows = executor.executePhysicalPlanAndGetResults(dedupAndVersionErrorSqlTypeSqlPlanMap.get(PK_DUPLICATE_ROWS), placeHolderKeyValues).get(0); String errorMessage = "Encountered multiple rows with duplicate primary keys, Failing the batch as Fail on Duplicate Primary Keys is selected"; LOGGER.error(errorMessage); - List dataErrors = IngestionUtils.constructDataQualityErrors(enrichedDatasets.stagingDataset(), duplicatePkRows.getData(), + List dataErrors = IngestionUtils.constructDataQualityErrors(enrichedDatasets.stagingDataset(), duplicatePkRows.data(), ErrorCategory.DUPLICATE_PRIMARY_KEYS, caseConversion, DeriveDuplicatePkRowsLogicalPlan.DUPLICATE_PK_COUNT, NUM_PK_DUPLICATES); throw new DataQualityException(errorMessage, dataErrors); } @@ -468,7 +468,7 @@ public static void dedupAndVersion(Executor execut TabularData errors = executor.executePhysicalPlanAndGetResults(dedupAndVersionErrorSqlTypeSqlPlanMap.get(DATA_ERROR_ROWS), placeHolderKeyValues).get(0); String errorMessage = "Encountered Data errors (same PK, same version but different data), hence failing the batch"; LOGGER.error(errorMessage); - List dataErrors = IngestionUtils.constructDataQualityErrors(enrichedDatasets.stagingDataset(), errors.getData(), + List dataErrors = IngestionUtils.constructDataQualityErrors(enrichedDatasets.stagingDataset(), errors.data(), ErrorCategory.DATA_VERSION_ERROR, caseConversion, DeriveDataErrorRowsLogicalPlan.DATA_VERSION_ERROR_COUNT, NUM_DATA_VERSION_ERRORS); throw new DataQualityException(errorMessage, dataErrors); } @@ -516,7 +516,7 @@ public static Map getFirstRowForFirstResult(List ta { Map resultMap = tabularData.stream() .findFirst() - .map(TabularData::getData) + .map(TabularData::data) .flatMap(t -> t.stream().findFirst()) .orElse(Collections.emptyMap()); return resultMap; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/executor/RelationalExecutor.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/executor/RelationalExecutor.java index 76857df5f2f..311a9a91af3 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/executor/RelationalExecutor.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/executor/RelationalExecutor.java @@ -16,10 +16,11 @@ import org.finos.legend.engine.persistence.components.executor.Executor; import org.finos.legend.engine.persistence.components.executor.RelationalExecutionHelper; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset; import org.finos.legend.engine.persistence.components.relational.RelationalSink; import org.finos.legend.engine.persistence.components.relational.SqlPlan; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.util.PlaceholderValue; import org.finos.legend.engine.persistence.components.util.SqlLogging; @@ -72,10 +73,10 @@ public List executePhysicalPlanAndGetResults(SqlPlan physicalPlan) for (String sql : physicalPlan.getSqlList()) { SqlUtils.logSql(LOGGER, sqlLogging, sql); - List> queryResult = relationalExecutionHelper.executeQuery(sql); - if (!queryResult.isEmpty()) + TabularData queryResultData = relationalExecutionHelper.executeQueryAndGetResultsAsTabularData(sql); + if (!queryResultData.data().isEmpty()) { - resultSetList.add(new TabularData(queryResult)); + resultSetList.add(queryResultData); } } return resultSetList; @@ -88,10 +89,10 @@ public List executePhysicalPlanAndGetResults(SqlPlan physicalPlan, for (String sql : physicalPlan.getSqlList()) { SqlUtils.logSql(LOGGER, sqlLogging, sql); - List> queryResult = relationalExecutionHelper.executeQuery(sql, rows); - if (!queryResult.isEmpty()) + TabularData queryResultData = relationalExecutionHelper.executeQueryAndGetResultsAsTabularData(sql, rows); + if (!queryResultData.data().isEmpty()) { - resultSetList.add(new TabularData(queryResult)); + resultSetList.add(queryResultData); } } return resultSetList; @@ -105,10 +106,10 @@ public List executePhysicalPlanAndGetResults(SqlPlan physicalPlan, { String enrichedSql = SqlUtils.getEnrichedSql(placeholderKeyValues, sql); SqlUtils.logSql(LOGGER, sqlLogging, sql, enrichedSql, placeholderKeyValues); - List> queryResult = relationalExecutionHelper.executeQuery(enrichedSql); - if (!queryResult.isEmpty()) + TabularData queryResultData = relationalExecutionHelper.executeQueryAndGetResultsAsTabularData(enrichedSql); + if (!queryResultData.data().isEmpty()) { - resultSetList.add(new TabularData(queryResult)); + resultSetList.add(queryResultData); } } return resultSetList; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java index 2031aa8cebd..a9a597fef34 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcHelper.java @@ -14,6 +14,8 @@ package org.finos.legend.engine.persistence.components.relational.jdbc; +import org.finos.legend.engine.persistence.components.executor.RelationalTransactionManager; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.executor.TypeMapping; import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset; import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition; @@ -47,6 +49,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.BiFunction; import java.util.regex.Pattern; public class JdbcHelper implements RelationalExecutionHelper @@ -54,7 +57,7 @@ public class JdbcHelper implements RelationalExecutionHelper private static final Logger LOGGER = LoggerFactory.getLogger(JdbcHelper.class); protected final Connection connection; - private JdbcTransactionManager transactionManager; + private RelationalTransactionManager transactionManager; public static final String TYPE_NAME = "TYPE_NAME"; public static final String DATA_TYPE = "DATA_TYPE"; @@ -81,12 +84,17 @@ public Connection connection() return connection; } + protected RelationalTransactionManager intializeTransactionManager(Connection connection) throws SQLException + { + return new JdbcTransactionManager(connection); + } + @Override public void beginTransaction() { try { - this.transactionManager = new JdbcTransactionManager(connection); + this.transactionManager = intializeTransactionManager(connection); this.transactionManager.beginTransaction(); } catch (SQLException e) @@ -434,10 +442,10 @@ public void executeStatements(List sqls) } else { - JdbcTransactionManager txManager = null; + RelationalTransactionManager txManager = null; try { - txManager = new JdbcTransactionManager(connection); + txManager = intializeTransactionManager(connection); txManager.beginTransaction(); for (String sql : sqls) { @@ -474,7 +482,7 @@ public void executeStatements(List sqls) } } - private void revertTransaction(JdbcTransactionManager txManager) + private void revertTransaction(RelationalTransactionManager txManager) { if (txManager != null) { @@ -494,41 +502,23 @@ public List> executeQuery(String sql, int rows) { if (this.transactionManager != null) { - try - { - return this.transactionManager.convertResultSetToList(sql, rows); - } - catch (SQLException e) - { - throw SqlExecutionExceptionMapper.from(e); - } + return getResult(this.transactionManager, sql, rows); } else { - JdbcTransactionManager txManager = null; - try - { - txManager = new JdbcTransactionManager(connection); - return txManager.convertResultSetToList(sql, rows); - } - catch (SQLException e) - { - throw SqlExecutionExceptionMapper.from(e); - } - finally - { - if (txManager != null) - { - try - { - txManager.close(); - } - catch (SQLException e) - { - LOGGER.error("Error closing transaction manager.", e); - } - } - } + return executeWithNewTransactionManager(sql, (manager, s) -> getResult(manager, s, rows)); + } + } + + private List> getResult(RelationalTransactionManager manager, String s, int rows) + { + try + { + return manager.convertResultSetToList(s, rows); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); } } @@ -537,39 +527,99 @@ public List> executeQuery(String sql) { if (this.transactionManager != null) { - try - { - return this.transactionManager.convertResultSetToList(sql); - } - catch (SQLException e) - { - throw SqlExecutionExceptionMapper.from(e); - } + return getResult(this.transactionManager, sql); } else { - JdbcTransactionManager txManager = null; - try - { - txManager = new JdbcTransactionManager(connection); - return txManager.convertResultSetToList(sql); - } - catch (SQLException e) - { - throw SqlExecutionExceptionMapper.from(e); - } - finally + return executeWithNewTransactionManager(sql, (manager, s) -> getResult(manager, s)); + } + } + + private List> getResult(RelationalTransactionManager manager, String s) + { + try + { + return manager.convertResultSetToList(s); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); + } + } + + @Override + public TabularData executeQueryAndGetResultsAsTabularData(String sql) + { + if (this.transactionManager != null) + { + return getTabularData(this.transactionManager, sql); + } + else + { + return executeWithNewTransactionManager(sql, (manager, s) -> getTabularData(manager, s)); + } + } + + private TabularData getTabularData(RelationalTransactionManager manager, String s) + { + try + { + return manager.convertResultSetToTabularData(s); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); + } + } + + @Override + public TabularData executeQueryAndGetResultsAsTabularData(String sql, int rows) + { + if (this.transactionManager != null) + { + return getTabularData(this.transactionManager, sql, rows); + } + else + { + return executeWithNewTransactionManager(sql, (manager, s) -> getTabularData(manager, s, rows)); + } + } + + private TabularData getTabularData(RelationalTransactionManager manager, String s, int rows) + { + try + { + return manager.convertResultSetToTabularData(s, rows); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); + } + } + + protected T executeWithNewTransactionManager(String sql, BiFunction transactionExecutor) + { + RelationalTransactionManager txManager = null; + try + { + txManager = intializeTransactionManager(connection); + return transactionExecutor.apply(txManager, sql); + } + catch (SQLException e) + { + throw SqlExecutionExceptionMapper.from(e); + } + finally + { + if (txManager != null) { - if (txManager != null) + try { - try - { - txManager.close(); - } - catch (SQLException e) - { - LOGGER.error("Error closing transaction manager.", e); - } + txManager.close(); + } + catch (SQLException e) + { + LOGGER.error("Error closing transaction manager.", e); } } } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java index e0d789b9323..cddd2430423 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/jdbc/JdbcTransactionManager.java @@ -14,6 +14,8 @@ package org.finos.legend.engine.persistence.components.relational.jdbc; +import org.finos.legend.engine.persistence.components.executor.RelationalTransactionManager; + import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.ResultSet; @@ -25,7 +27,7 @@ import java.util.List; import java.util.Map; -public class JdbcTransactionManager +public class JdbcTransactionManager implements RelationalTransactionManager { protected final Statement statement; private Connection connection; @@ -105,7 +107,7 @@ public List> convertResultSetToList(String sql, int rows) th return resultList; } - private static void extractResults(List> resultList, ResultSet resultSet) throws SQLException + protected static void extractResults(List> resultList, ResultSet resultSet) throws SQLException { ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = resultSet.getMetaData().getColumnCount(); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/common/FunctionName.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/common/FunctionName.java index beddc9a7c10..4ed8dc41962 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/common/FunctionName.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/common/FunctionName.java @@ -52,6 +52,7 @@ public enum FunctionName TO_JSON("TO_JSON"), CONVERT("CONVERT"), STRUCT("STRUCT"), + JSON_EXTRACT_PATH_TEXT("JSON_EXTRACT_PATH_TEXT"), APPROX_COUNT_DISTINCT("APPROX_COUNT_DISTINCT"); private static final Map BY_NAME = Arrays diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/schemaops/expresssions/table/TableFunction.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/schemaops/expresssions/table/TableFunction.java new file mode 100644 index 00000000000..203ec853afd --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/main/java/org/finos/legend/engine/persistence/components/relational/sqldom/schemaops/expresssions/table/TableFunction.java @@ -0,0 +1,97 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.expresssions.table; + +import java.util.List; +import org.finos.legend.engine.persistence.components.relational.sqldom.SqlDomException; +import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.values.Value; +import org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils; +import org.finos.legend.engine.persistence.components.relational.sqldom.utils.StringUtils; + +import static org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils.CLOSING_PARENTHESIS; +import static org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils.COMMA; +import static org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils.OPEN_PARENTHESIS; + +public class TableFunction extends TableLike +{ + public static final String TABLE = "TABLE"; + private final String db; + private final String schema; + private String name; + private final List values; + private final String quoteIdentifier; + + public TableFunction(String db, String schema, String name, List values, String quoteIdentifier) + { + this.db = db; + this.schema = schema; + this.name = name; + this.values = values; + this.quoteIdentifier = quoteIdentifier; + } + + @Override + public void genSql(StringBuilder builder) throws SqlDomException + { + genSqlWithoutAlias(builder); + super.genSql(builder); + } + + @Override + public void genSqlWithoutAlias(StringBuilder builder) throws SqlDomException + { + if (StringUtils.notEmpty(db)) + { + builder.append(String.format("%s.", SqlGenUtils.getQuotedField(db, quoteIdentifier))); + } + + if (StringUtils.notEmpty(schema)) + { + builder.append(String.format("%s.", SqlGenUtils.getQuotedField(schema, quoteIdentifier))); + } + + builder.append(TABLE); + builder.append(OPEN_PARENTHESIS); + + builder.append(name); + builder.append(OPEN_PARENTHESIS); + if (values != null) + { + for (int ctr = 0; ctr < values.size(); ctr++) + { + values.get(ctr).genSqlWithoutAlias(builder); + if (ctr < (values.size() - 1)) + { + builder.append(COMMA); + } + } + } + builder.append(CLOSING_PARENTHESIS); + builder.append(CLOSING_PARENTHESIS); + } + + @Override + public void push(Object node) + { + if (node instanceof String) + { + name = (String) node; + } + else if (node instanceof Value) + { + values.add((Value) node); + } + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/test/java/org/finos/legend/engine/persistence/components/relational/sqldom/schemaops/TableFunctionTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/test/java/org/finos/legend/engine/persistence/components/relational/sqldom/schemaops/TableFunctionTest.java new file mode 100644 index 00000000000..a6834d131ab --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-core/src/test/java/org/finos/legend/engine/persistence/components/relational/sqldom/schemaops/TableFunctionTest.java @@ -0,0 +1,82 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.relational.sqldom.schemaops; + +import java.util.ArrayList; +import java.util.Collections; +import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.expresssions.table.TableFunction; +import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.values.Field; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class TableFunctionTest +{ + @Test + public void testTableFunctionWithoutSchemaAndParams() + { + TableFunction tableFunction = new TableFunction( + null, + null, + "STATS", + new ArrayList<>(), + BaseTest.QUOTE_IDENTIFIER + ); + String sql = BaseTest.genSql(tableFunction); + assertEquals("TABLE(STATS())", sql); + } + + @Test + public void testTableFunctionWithParams() + { + TableFunction tableFunction = new TableFunction( + null, + null, + "STATS", + Collections.singletonList(new Field(null, "id", BaseTest.QUOTE_IDENTIFIER, null)), + BaseTest.QUOTE_IDENTIFIER + ); + String sql = BaseTest.genSql(tableFunction); + assertEquals("TABLE(STATS(\"id\"))", sql); + } + + @Test + public void testTableFunctionWithSchema() + { + TableFunction tableFunction = new TableFunction( + null, + "information_schema", + "STATS", + null, + BaseTest.QUOTE_IDENTIFIER + ); + String sql = BaseTest.genSql(tableFunction); + assertEquals("\"information_schema\".TABLE(STATS())", sql); + } + + @Test + public void testTableFunctionWithDbAndSchema() + { + TableFunction tableFunction = new TableFunction( + "prod", + "information_schema", + "STATS", + null, + BaseTest.QUOTE_IDENTIFIER + ); + String sql = BaseTest.genSql(tableFunction); + assertEquals("\"prod\".\"information_schema\".TABLE(STATS())", sql); + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/pom.xml index 288aeb7fb09..a7f03374641 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/main/java/org/finos/legend/engine/persistence/components/relational/duckdb/DuckDBSink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/main/java/org/finos/legend/engine/persistence/components/relational/duckdb/DuckDBSink.java index 6bcce373f1c..5a9d58c717b 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/main/java/org/finos/legend/engine/persistence/components/relational/duckdb/DuckDBSink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/main/java/org/finos/legend/engine/persistence/components/relational/duckdb/DuckDBSink.java @@ -58,7 +58,7 @@ import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcConnection; import org.finos.legend.engine.persistence.components.relational.duckdb.sql.visitor.FieldVisitor; import org.finos.legend.engine.persistence.components.relational.duckdb.sql.visitor.SchemaDefinitionVisitor; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils; import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; @@ -224,7 +224,7 @@ public IngestorResult performBulkLoad(Datasets datasets, Executor t.stream().findFirst()) .map(Map::values) .flatMap(t -> t.stream().findFirst()) diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java index 17e11647f1d..34c35397337 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-duckdb/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java @@ -211,8 +211,8 @@ void testMilestoningWithOptimizationFilters() throws Exception .dateTimeInName(batchTimeInName) .dateTimeOutName(batchTimeOutName) .build()) - .addOptimizationFilters(OptimizationFilter.of(expiryDateName, expiryDateName + "_lower", expiryDateName + "_upper")) - .addOptimizationFilters(OptimizationFilter.of(idName, idName + "_lower", idName + "_upper")) + .addOptimizationFilters(OptimizationFilter.of(expiryDateName)) + .addOptimizationFilters(OptimizationFilter.of(idName)) .build(); PlannerOptions options = PlannerOptions.builder().cleanupStagingData(false).collectStatistics(true).build(); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/pom.xml index 4f986ea6379..9f445f19085 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/H2Sink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/H2Sink.java index 9878e745d24..c7d720c5cda 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/H2Sink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/main/java/org/finos/legend/engine/persistence/components/relational/h2/H2Sink.java @@ -80,7 +80,7 @@ import org.finos.legend.engine.persistence.components.util.Capability; import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcConnection; import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcHelper; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.executor.RelationalExecutor; import org.finos.legend.engine.persistence.components.util.PlaceholderValue; @@ -231,7 +231,7 @@ public IngestorResult performBulkLoad(Datasets datasets, Executor t.stream().findFirst()) .map(Map::values) .flatMap(t -> t.stream().findFirst()) @@ -315,7 +315,7 @@ public List performDryRunWithValidationQueries(Datasets datasets, Tra List results = executor.executePhysicalPlanAndGetResults(transformer.generatePhysicalPlan(LogicalPlanFactory.getLogicalPlanForSelectAllFieldsWithStringFieldEquals(validatedColumn, problematicValue.get())), sampleRowCount); if (!results.isEmpty()) { - List> resultSets = results.get(0).getData(); + List> resultSets = results.get(0).data(); for (Map row : resultSets) { DataError dataError = constructDataError(allFields, row, TYPE_CONVERSION, validatedColumn.fieldName(), caseConversion); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/BaseTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/BaseTest.java index 0c02ac68d8c..732e532e137 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/BaseTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/BaseTest.java @@ -197,6 +197,46 @@ protected IngestorResult executePlansAndVerifyResults(IngestMode ingestMode, Pla return executePlansAndVerifyResults(ingestor, datasets, schema, expectedDataPath, expectedStats, verifyStagingFilters); } + protected IngestorResult executePlansAndVerifyResultsUsingLightweightCreate(IngestMode ingestMode, Datasets datasets, + String[] schema, String expectedDataPath, Map expectedStats, + Clock executionTimestampClock, boolean verifyStagingFilters) throws Exception + { + RelationalIngestor ingestor = RelationalIngestor.builder() + .ingestMode(ingestMode) + .relationalSink(H2Sink.get()) + .executionTimestampClock(executionTimestampClock) + .collectStatistics(true) + .enableConcurrentSafety(true) + .cleanupStagingData(false) + .build(); + + Executor executor = ingestor.initExecutor(JdbcConnection.of(h2Sink.connection())); + ingestor.create(datasets); + ingestor.initDatasets(datasets); + executor.begin(); + IngestorResult result = ingestor.ingest().get(0); + executor.commit(); + ingestor.cleanUp(); + + Map actualStats = result.statisticByName(); + + // Verify the database data + List> tableData = h2Sink.executeQuery("select * from \"TEST\".\"main\""); + TestUtils.assertFileAndTableDataEquals(schema, expectedDataPath, tableData); + + // Verify statistics + verifyStats(expectedStats, actualStats); + + // Verify StagingFilters + if (verifyStagingFilters) + { + verifyLatestStagingFilters(ingestor, datasets); + } + + // Return result (including updated datasets) + return result; + } + protected IngestorResult executePlansAndVerifyResults(RelationalIngestor ingestor, Datasets datasets, String[] schema, String expectedDataPath, Map expectedStats, boolean verifyStagingFilters) throws Exception { diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/RelationalSchemaEvolutionServiceTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/RelationalSchemaEvolutionServiceTest.java index 17d64d089c7..21bc3dcd310 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/RelationalSchemaEvolutionServiceTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/RelationalSchemaEvolutionServiceTest.java @@ -18,9 +18,7 @@ import org.finos.legend.engine.persistence.components.ingestmode.audit.DateTimeAuditing; import org.finos.legend.engine.persistence.components.ingestmode.deduplication.FilterDuplicates; import org.finos.legend.engine.persistence.components.ingestmode.digest.UserProvidedDigestGenStrategy; -import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition; -import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetReference; -import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetReferenceImpl; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.*; import org.finos.legend.engine.persistence.components.relational.CaseConversion; import org.finos.legend.engine.persistence.components.relational.api.RelationalSchemaEvolutionService; import org.finos.legend.engine.persistence.components.relational.api.SchemaEvolutionServiceResult; @@ -98,7 +96,13 @@ void testAddColumnUpperCase() throws Exception { DatasetDefinition mainTable = TestUtils.getSchemaEvolutionAddColumnMainTableUpperCase(); // This is only used to create a database table in upper case DatasetDefinition stagingTable = TestUtils.getBasicStagingTable(); - DatasetReference mainTableDatasetReference = DatasetReferenceImpl.builder().group(testSchemaName).name(mainTableName).build(); // This is the model user has + DatasetReference mainTableDatasetReference = DatasetReferenceImpl.builder().group(testSchemaName) + .name(mainTableName) + .datasetAdditionalProperties(DatasetAdditionalProperties.builder().tableOrigin(TableOrigin.ICEBERG).build()) + .build(); // This is the model user has + + Assertions.assertEquals(DatasetAdditionalProperties.builder().tableOrigin(TableOrigin.ICEBERG).build(), + mainTableDatasetReference.datasetAdditionalProperties().get()); // Create staging table createStagingTable(stagingTable); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaWithBatchIdTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaWithBatchIdTest.java index fa339e39789..dfd4e9df8e6 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaWithBatchIdTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/bitemporal/BitemporalDeltaWithBatchIdTest.java @@ -1094,6 +1094,10 @@ void testMilestoningSourceSpecifiesFromWithDeleteIndicatorSet1() throws Exceptio // 2. Execute Plan and Verify Results expectedStats = createExpectedStatsMap(1, 0, 0, 1, 0); executePlansAndVerifyResults(ingestMode, options, datasets, schema, expectedDataPass6, expectedStats); + + // Verify temp tables are dropped + Assertions.assertFalse(h2Sink.doesTableExist(tempTable)); + Assertions.assertFalse(h2Sink.doesTableExist(tempTableWithDeleteIndicator)); } /* diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaTest.java index 58d76d3f19d..5d1a2170a38 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/unitemporal/UnitemporalDeltaTest.java @@ -214,8 +214,8 @@ void testMilestoningWithOptimizationFilters() throws Exception .dateTimeInName(batchTimeInName) .dateTimeOutName(batchTimeOutName) .build()) - .addOptimizationFilters(OptimizationFilter.of(expiryDateName, expiryDateName + "_lower", expiryDateName + "_upper")) - .addOptimizationFilters(OptimizationFilter.of(idName, idName + "_lower", idName + "_upper")) + .addOptimizationFilters(OptimizationFilter.of(expiryDateName)) + .addOptimizationFilters(OptimizationFilter.of(idName)) .build(); PlannerOptions options = PlannerOptions.builder().cleanupStagingData(false).collectStatistics(true).build(); @@ -250,6 +250,15 @@ void testMilestoningWithOptimizationFilters() throws Exception // 2. Execute plans and verify results expectedStats = createExpectedStatsMap(0, 0, 0, 0, 0); executePlansAndVerifyResults(ingestMode, options, datasets, schema, expectedDataPass3, expectedStats); + + // ------------ Perform Pass4 with lower bound equals upper bound ------------------------- + String dataPass4 = basePathForInput + "with_optimization_filter/staging_data_pass4.csv"; + String expectedDataPass4 = basePathForExpected + "with_optimization_filter/expected_pass4.csv"; + // 1. Load staging table + loadBasicStagingData(dataPass4); + // 2. Execute plans and verify results + expectedStats = createExpectedStatsMap(1, 0, 0, 1, 0); + executePlansAndVerifyResults(ingestMode, options, datasets, schema, expectedDataPass4, expectedStats, fixedClock_2000_01_01); } @Test diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/logicalplan/operations/LightweightCreateApiTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/logicalplan/operations/LightweightCreateApiTest.java new file mode 100644 index 00000000000..f45a9e1a046 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/logicalplan/operations/LightweightCreateApiTest.java @@ -0,0 +1,209 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.logicalplan.operations; + +import org.finos.legend.engine.persistence.components.BaseTest; +import org.finos.legend.engine.persistence.components.TestUtils; +import org.finos.legend.engine.persistence.components.common.Datasets; +import org.finos.legend.engine.persistence.components.ingestmode.UnitemporalDelta; +import org.finos.legend.engine.persistence.components.ingestmode.deduplication.FailOnDuplicates; +import org.finos.legend.engine.persistence.components.ingestmode.deduplication.FilterDuplicates; +import org.finos.legend.engine.persistence.components.ingestmode.transactionmilestoning.BatchIdAndDateTime; +import org.finos.legend.engine.persistence.components.ingestmode.versioning.DigestBasedResolver; +import org.finos.legend.engine.persistence.components.ingestmode.versioning.MaxVersionStrategy; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetReference; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetReferenceImpl; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.DerivedDataset; +import org.finos.legend.engine.persistence.components.relational.CaseConversion; +import org.finos.legend.engine.persistence.components.relational.api.RelationalIngestor; +import org.finos.legend.engine.persistence.components.relational.h2.H2Sink; +import org.finos.legend.engine.persistence.components.util.MetadataDataset; +import org.finos.legend.engine.persistence.components.util.TableNameGenUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.finos.legend.engine.persistence.components.TestUtils.batchIdInName; +import static org.finos.legend.engine.persistence.components.TestUtils.batchIdOutName; +import static org.finos.legend.engine.persistence.components.TestUtils.batchTimeInName; +import static org.finos.legend.engine.persistence.components.TestUtils.batchTimeOutName; +import static org.finos.legend.engine.persistence.components.TestUtils.digestName; +import static org.finos.legend.engine.persistence.components.TestUtils.expiryDateName; +import static org.finos.legend.engine.persistence.components.TestUtils.idName; +import static org.finos.legend.engine.persistence.components.TestUtils.incomeName; +import static org.finos.legend.engine.persistence.components.TestUtils.nameName; +import static org.finos.legend.engine.persistence.components.TestUtils.startTimeName; +import static org.finos.legend.engine.persistence.components.TestUtils.versionName; +import static org.finos.legend.engine.persistence.components.relational.api.utils.ApiUtils.LOCK_INFO_DATASET_SUFFIX; +import static org.finos.legend.engine.persistence.components.util.TableNameGenUtils.TEMP_STAGING_DATASET_QUALIFIER; + + +class LightweightCreateApiTest extends BaseTest +{ + private final String basePathForInput = "src/test/resources/data/unitemporal-incremental-milestoning/input/batch_id_and_time_based/"; + private final String basePathForExpected = "src/test/resources/data/unitemporal-incremental-milestoning/expected/batch_id_and_time_based/"; + + @Test + void testApiBasic() + { + DatasetDefinition mainTable = TestUtils.getDefaultMainTable(); + DatasetDefinition stagingTable = TestUtils.getBasicStagingTable(); + + UnitemporalDelta ingestMode = UnitemporalDelta.builder() + .digestField(digestName) + .transactionMilestoning(BatchIdAndDateTime.builder() + .batchIdInName(batchIdInName) + .batchIdOutName(batchIdOutName) + .dateTimeInName(batchTimeInName) + .dateTimeOutName(batchTimeOutName) + .build()) + .build(); + + RelationalIngestor ingestor = RelationalIngestor.builder() + .ingestMode(ingestMode) + .relationalSink(H2Sink.get()) + .build(); + + // Calling API + ingestor.initExecutor(executor); + ingestor.create(Datasets.builder().mainDataset(mainTable).stagingDataset(stagingTable).build()); + + // Asserting on table creation + Assertions.assertTrue(h2Sink.doesTableExist(mainTable)); + Assertions.assertTrue(h2Sink.doesTableExist(MetadataDataset.builder().build().get())); + } + + @Test + void testApiWithTempTablesAndCaseConversion() + { + DatasetDefinition mainTable = TestUtils.getDefaultMainTable(); + DatasetDefinition stagingTable = TestUtils.getBasicStagingTable(); + + UnitemporalDelta ingestMode = UnitemporalDelta.builder() + .deduplicationStrategy(FailOnDuplicates.builder().build()) + .digestField(digestName) + .transactionMilestoning(BatchIdAndDateTime.builder() + .batchIdInName(batchIdInName) + .batchIdOutName(batchIdOutName) + .dateTimeInName(batchTimeInName) + .dateTimeOutName(batchTimeOutName) + .build()) + .build(); + + RelationalIngestor ingestor = RelationalIngestor.builder() + .ingestMode(ingestMode) + .relationalSink(H2Sink.get()) + .enableConcurrentSafety(true) + .executionTimestampClock(fixedClock_2000_01_01) + .caseConversion(CaseConversion.TO_UPPER) + .build(); + + // Calling API + ingestor.initExecutor(executor); + ingestor.create(Datasets.builder().mainDataset(mainTable).stagingDataset(stagingTable).build()); + + // Asserting on table creation + String ingestRunId = ingestor.getRunId(); + String tempStagingTableName = TableNameGenUtils.generateTableName(stagingTable.name(), TEMP_STAGING_DATASET_QUALIFIER, ingestRunId); + DatasetReference tempStagingTable = DatasetReferenceImpl.builder().database(stagingTable.database()).group(stagingTable.group()).name(tempStagingTableName).build(); + String lockTableName = mainTable.name() + LOCK_INFO_DATASET_SUFFIX; + DatasetReference lockTable = DatasetReferenceImpl.builder().database(mainTable.database()).group(mainTable.group()).name(lockTableName).build(); + + Assertions.assertTrue(h2Sink.doesTableExist(convertDatasetToUpperCase(mainTable))); + Assertions.assertTrue(h2Sink.doesTableExist(convertDatasetToUpperCase(MetadataDataset.builder().build().get()))); + Assertions.assertTrue(h2Sink.doesTableExist(convertDatasetToUpperCase(tempStagingTable))); + Assertions.assertTrue(h2Sink.doesTableExist(convertDatasetToUpperCase(lockTable))); + + // Asserting on lock table initialization + List> tableData = h2Sink.executeQuery("select * from \"TEST\".\"" + lockTableName.toUpperCase() + "\""); + Assertions.assertEquals("2000-01-01 00:00:00.0", tableData.get(0).get("INSERT_TS_UTC").toString()); + } + + @Test + void testEndToEnd() throws Exception + { + DatasetDefinition mainTable = TestUtils.getUnitemporalMainTableWithVersion(); + DerivedDataset stagingTable = TestUtils.getDerivedStagingTableWithFilterWithVersion(); + + String[] schema = new String[]{idName, nameName, incomeName, startTimeName, expiryDateName, digestName, versionName, batchIdInName, batchIdOutName, batchTimeInName, batchTimeOutName}; + + // Create staging table + DatasetDefinition stagingTableForDB = TestUtils.getStagingTableWithFilterWithVersionForDB(); + createStagingTable(stagingTableForDB); + + UnitemporalDelta ingestMode = UnitemporalDelta.builder() + .digestField(digestName) + .transactionMilestoning(BatchIdAndDateTime.builder() + .batchIdInName(batchIdInName) + .batchIdOutName(batchIdOutName) + .dateTimeInName(batchTimeInName) + .dateTimeOutName(batchTimeOutName) + .build()) + .versioningStrategy(MaxVersionStrategy.builder() + .versioningField(versionName) + .mergeDataVersionResolver(DigestBasedResolver.INSTANCE) + .performStageVersioning(true) + .build()) + .deduplicationStrategy(FilterDuplicates.builder().build()) + .build(); + + Datasets datasets = Datasets.of(mainTable, stagingTable); + + // ------------ Perform Pass1 ------------------------ + String dataPass1 = basePathForInput + "with_staging_filter/with_max_versioning/digest_based/staging_data_pass1.csv"; + String expectedDataPass1 = basePathForExpected + "with_staging_filter/with_max_versioning/digest_based/expected_pass1.csv"; + // 1. Load staging table + loadStagingDataWithFilterWithVersion(dataPass1); + // 2. Execute plans and verify results + Map expectedStats = createExpectedStatsMap(3, 0, 3, 0, 0); + executePlansAndVerifyResultsUsingLightweightCreate(ingestMode, datasets, schema, expectedDataPass1, expectedStats, fixedClock_2000_01_01, true); + // 3. Assert that the staging table is NOT truncated + List> stagingTableList = h2Sink.executeQuery("select * from \"TEST\".\"staging\""); + Assertions.assertEquals(stagingTableList.size(), 6); + + // ------------ Perform Pass2 ------------------------ + // 0. Create new filter + datasets = Datasets.of(mainTable, TestUtils.getStagingTableWithFilterWithVersionSecondPass()); + String dataPass2 = basePathForInput + "with_staging_filter/with_max_versioning/digest_based/staging_data_pass2.csv"; + String expectedDataPass2 = basePathForExpected + "with_staging_filter/with_max_versioning/digest_based/expected_pass2.csv"; + // 1. Load staging table + loadStagingDataWithFilterWithVersion(dataPass2); + // 2. Execute plans and verify results + expectedStats = createExpectedStatsMap(9, 0, 1, 2, 0); + executePlansAndVerifyResultsUsingLightweightCreate(ingestMode, datasets, schema, expectedDataPass2, expectedStats, fixedClock_2000_01_01, true); + + // ------------ Perform Pass3 empty batch (No Impact) ------------------------- + String dataPass3 = "src/test/resources/data/empty_file.csv"; + String expectedDataPass3 = basePathForExpected + "with_staging_filter/with_max_versioning/digest_based/expected_pass3.csv"; + // 1. Load staging table + loadStagingDataWithFilterWithVersion(dataPass3); + // 2. Execute plans and verify results + expectedStats = createExpectedStatsMap(0, 0, 0, 0, 0); + executePlansAndVerifyResultsUsingLightweightCreate(ingestMode, datasets, schema, expectedDataPass3, expectedStats, fixedClock_2000_01_01, true); + } + + private Dataset convertDatasetToUpperCase(Dataset dataset) + { + return DatasetReferenceImpl.builder() + .database(dataset.datasetReference().database().map(String::toUpperCase)) + .group(dataset.datasetReference().group().map(String::toUpperCase)) + .name(dataset.datasetReference().name().map(String::toUpperCase)) + .build(); + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/logicalplan/operations/ShowTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/logicalplan/operations/ShowTest.java index f02b4983c17..fd817dc0c2f 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/logicalplan/operations/ShowTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/java/org/finos/legend/engine/persistence/components/logicalplan/operations/ShowTest.java @@ -21,7 +21,7 @@ import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition; import org.finos.legend.engine.persistence.components.relational.SqlPlan; import org.finos.legend.engine.persistence.components.relational.h2.H2Sink; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -43,8 +43,8 @@ public void testShowCommand() throws Exception SqlPlan physicalPlan = transformer.generatePhysicalPlan(logicalPlan); List result = executor.executePhysicalPlanAndGetResults(physicalPlan); - Assertions.assertEquals(1, result.get(0).getData().size()); - Assertions.assertEquals("staging", result.get(0).getData().get(0).get("TABLE_NAME")); + Assertions.assertEquals(1, result.get(0).data().size()); + Assertions.assertEquals("staging", result.get(0).data().get(0).get("TABLE_NAME")); h2Sink.executeStatement("DROP TABLE TEST_DB.TEST.staging"); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/resources/data/unitemporal-incremental-milestoning/expected/batch_id_and_time_based/with_optimization_filter/expected_pass4.csv b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/resources/data/unitemporal-incremental-milestoning/expected/batch_id_and_time_based/with_optimization_filter/expected_pass4.csv new file mode 100644 index 00000000000..d363f0a57c0 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/resources/data/unitemporal-incremental-milestoning/expected/batch_id_and_time_based/with_optimization_filter/expected_pass4.csv @@ -0,0 +1,6 @@ +1,HARRY,1000,2020-01-01 00:00:00.0,2022-12-01,DIGEST1,1,999999999,2000-01-01 00:00:00.0,9999-12-31 23:59:59.0 +2,ROBERT,2000,2020-01-02 00:00:00.0,2022-12-02,DIGEST2,1,1,2000-01-01 00:00:00.0,2000-01-01 00:00:00.0 +3,ANDY,3000,2020-01-03 00:00:00.0,2022-12-03,DIGEST3,1,999999999,2000-01-01 00:00:00.0,9999-12-31 23:59:59.0 +2,ROBERT,4000,2020-01-02 00:00:00.0,2022-12-02,DIGEST2_UPDATED,2,999999999,2000-01-01 00:00:00.0,9999-12-31 23:59:59.0 +4,MATT,6000,2020-01-06 00:00:00.0,2022-12-06,DIGEST4,2,3,2000-01-01 00:00:00.0,2000-01-01 00:00:00.0 +4,MATT,6001,2020-01-06 00:00:00.0,2022-12-06,DIGEST4_UPDATED,4,999999999,2000-01-01 00:00:00.0,9999-12-31 23:59:59.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/resources/data/unitemporal-incremental-milestoning/input/batch_id_and_time_based/with_optimization_filter/staging_data_pass4.csv b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/resources/data/unitemporal-incremental-milestoning/input/batch_id_and_time_based/with_optimization_filter/staging_data_pass4.csv new file mode 100644 index 00000000000..28fc0674485 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-h2/src/test/resources/data/unitemporal-incremental-milestoning/input/batch_id_and_time_based/with_optimization_filter/staging_data_pass4.csv @@ -0,0 +1 @@ +4,MATT,6001,2020-01-06 00:00:00.0,2022-12-06,DIGEST4_UPDATED diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/pom.xml index 4c47528f857..ff4f9375095 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/main/java/org/finos/legend/engine/persistence/components/relational/memsql/MemSqlSink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/main/java/org/finos/legend/engine/persistence/components/relational/memsql/MemSqlSink.java index b10b245d05e..2875a54bcc9 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/main/java/org/finos/legend/engine/persistence/components/relational/memsql/MemSqlSink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/main/java/org/finos/legend/engine/persistence/components/relational/memsql/MemSqlSink.java @@ -53,7 +53,7 @@ import org.finos.legend.engine.persistence.components.relational.memsql.sql.visitor.SQLCreateVisitor; import org.finos.legend.engine.persistence.components.relational.memsql.sql.visitor.FieldVisitor; import org.finos.legend.engine.persistence.components.relational.sql.DataTypeMapping; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.constraints.column.ColumnConstraint; import org.finos.legend.engine.persistence.components.relational.sqldom.constraints.column.NotNullColumnConstraint; @@ -197,7 +197,7 @@ public void execute(Executor executor, RelationalE List userColumns = JdbcHelper.convertUserProvidedFieldsToColumns(userFields, new MemSqlDataTypeMapping()); List dbColumns = new ArrayList<>(); - for (Map m : results.get(0).getData()) + for (Map m : results.get(0).data()) { String columnName = (String) m.get("Field"); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java index 774777052cf..2f7c5ceaadb 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BitemporalDeltaSourceSpecifiesFromTest.java @@ -309,8 +309,8 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndNoDataSplits(Generator @Override public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplits(List operations, List dataSplitRanges) { - String tempName = operations.get(0).preActionsSql().get(2).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String tempWithDeleteIndicatorName = operations.get(0).preActionsSql().get(3).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; + String tempName = "`mydb`.`main_legend_persistence_temp_lp_yosulf`"; + String tempWithDeleteIndicatorName = "`mydb`.`main_legend_persistence_tempWithDeleteIndicator_lp_yosulf`"; String expectedBitemporalFromOnlyDefaultTempTableCreateQuery = "CREATE TABLE IF NOT EXISTS " + tempName + "(`id` INTEGER NOT NULL," + @@ -765,9 +765,9 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndNoDataSplitsFilterDupl @Override public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDuplicates(List operations, List dataSplitRanges) { - String tempName = operations.get(0).preActionsSql().get(2).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String tempWithDeleteIndicatorName = operations.get(0).preActionsSql().get(3).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; - String stageWithoutDuplicatesName = operations.get(0).preActionsSql().get(4).split("CREATE TABLE IF NOT EXISTS ")[1].split("\\(")[0]; + String tempName = "`mydb`.`main_legend_persistence_temp_lp_yosulf`"; + String tempWithDeleteIndicatorName = "`mydb`.`main_legend_persistence_tempWithDeleteIndicator_lp_yosulf`"; + String stageWithoutDuplicatesName = "`mydb`.`staging_legend_persistence_stageWithoutDuplicates_lp_yosulf`"; String expectedBitemporalFromOnlyDefaultTempTableCreateQuery = "CREATE TABLE IF NOT EXISTS " + tempName + "(`id` INTEGER NOT NULL," + @@ -929,9 +929,9 @@ public void verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDu Assertions.assertEquals(getExpectedMetadataTableIngestQuery(), operations.get(0).metadataIngestSql().get(0)); - Assertions.assertEquals(getDropTempTableQuery("`mydb`.`main_legend_persistence_temp`"), operations.get(0).postCleanupSql().get(0)); - Assertions.assertEquals(getDropTempTableQuery("`mydb`.`main_legend_persistence_tempWithDeleteIndicator`"), operations.get(0).postCleanupSql().get(1)); - Assertions.assertEquals(getDropTempTableQuery("`mydb`.`staging_legend_persistence_stageWithoutDuplicates`"), operations.get(0).postCleanupSql().get(2)); + Assertions.assertEquals(getDropTempTableQuery(tempName), operations.get(0).postCleanupSql().get(0)); + Assertions.assertEquals(getDropTempTableQuery(tempWithDeleteIndicatorName), operations.get(0).postCleanupSql().get(1)); + Assertions.assertEquals(getDropTempTableQuery(stageWithoutDuplicatesName), operations.get(0).postCleanupSql().get(2)); Assertions.assertEquals(2, operations.size()); String incomingRecordCount = "SELECT COUNT(*) as `incomingRecordCount` FROM `mydb`.`staging` as stage WHERE (stage.`data_split` >= '{DATA_SPLIT_LOWER_BOUND_PLACEHOLDER}') AND (stage.`data_split` <= '{DATA_SPLIT_UPPER_BOUND_PLACEHOLDER}')"; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java index 4f48a513e1d..5c0c160c3c2 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-memsql/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java @@ -239,7 +239,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe String expectedMilestoneQuery = "UPDATE `mydb`.`main` as sink " + "SET sink.`batch_id_out` = (SELECT COALESCE(MAX(batch_metadata.`table_batch_id`),0)+1 FROM batch_metadata as batch_metadata " + "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN')-1 WHERE " + - "(sink.`batch_id_out` = 999999999) AND ((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')) " + + "(sink.`batch_id_out` = 999999999) AND ((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')) " + "AND (EXISTS (SELECT * FROM `mydb`.`staging` as stage WHERE ((sink.`id` = stage.`id`) " + "AND (sink.`name` = stage.`name`)) AND (sink.`digest` <> stage.`digest`)))"; @@ -250,7 +250,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN'),999999999 FROM `mydb`.`staging` as stage " + "WHERE NOT (EXISTS (SELECT * FROM `mydb`.`main` as sink WHERE (sink.`batch_id_out` = 999999999) AND " + "(sink.`digest` = stage.`digest`) AND ((sink.`id` = stage.`id`) AND (sink.`name` = stage.`name`)) AND " + - "((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')))))"; + "((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')))))"; Assertions.assertEquals(MemsqlTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(MemsqlTestArtifacts.expectedMetadataTableCreateQuery, preActionsSql.get(1)); @@ -270,7 +270,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull String expectedMilestoneQuery = "UPDATE `mydb`.`main` as sink " + "SET sink.`batch_id_out` = (SELECT COALESCE(MAX(batch_metadata.`table_batch_id`),0)+1 FROM batch_metadata as batch_metadata " + "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN')-1 WHERE " + - "(sink.`batch_id_out` = 999999999) AND (((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')) OR (sink.`id` IS NULL)) " + + "(sink.`batch_id_out` = 999999999) AND (((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')) OR (sink.`id` IS NULL)) " + "AND (EXISTS (SELECT * FROM `mydb`.`staging` as stage WHERE ((sink.`id` = stage.`id`) " + "AND (sink.`name` = stage.`name`)) AND (sink.`digest` <> stage.`digest`)))"; @@ -281,7 +281,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull "WHERE UPPER(batch_metadata.`table_name`) = 'MAIN'),999999999 FROM `mydb`.`staging` as stage " + "WHERE NOT (EXISTS (SELECT * FROM `mydb`.`main` as sink WHERE (sink.`batch_id_out` = 999999999) AND " + "(sink.`digest` = stage.`digest`) AND ((sink.`id` = stage.`id`) AND (sink.`name` = stage.`name`)) AND " + - "(((sink.`id` >= '{ID_LOWER_BOUND}') AND (sink.`id` <= '{ID_UPPER_BOUND}')) OR (sink.`id` IS NULL)))))"; + "(((sink.`id` >= '{id_legend_persistence_lower}') AND (sink.`id` <= '{id_legend_persistence_upper}')) OR (sink.`id` IS NULL)))))"; Assertions.assertEquals(MemsqlTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(MemsqlTestArtifacts.expectedMetadataTableCreateQuery, preActionsSql.get(1)); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/pom.xml index f7c4b06949a..b5667a48143 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/main/java/org/finos/legend/engine/persistence/components/relational/postgres/PostgresSink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/main/java/org/finos/legend/engine/persistence/components/relational/postgres/PostgresSink.java index 9b0ca61ab35..f4ba89b97b3 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/main/java/org/finos/legend/engine/persistence/components/relational/postgres/PostgresSink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/main/java/org/finos/legend/engine/persistence/components/relational/postgres/PostgresSink.java @@ -42,7 +42,7 @@ import org.finos.legend.engine.persistence.components.relational.postgres.sql.PostgresDataTypeMapping; import org.finos.legend.engine.persistence.components.relational.postgres.sql.PostgresJdbcPropertiesToLogicalDataTypeMapping; import org.finos.legend.engine.persistence.components.relational.postgres.sql.visitor.*; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils; import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/BaseTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/BaseTest.java index 59eef3c2be9..7e6607e1473 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/BaseTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/BaseTest.java @@ -14,12 +14,8 @@ package org.finos.legend.engine.persistence.components.e2e; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import org.finos.legend.engine.persistence.components.common.DatasetFilter; import org.finos.legend.engine.persistence.components.common.Datasets; -import org.finos.legend.engine.persistence.components.common.FilterType; import org.finos.legend.engine.persistence.components.common.StatisticName; import org.finos.legend.engine.persistence.components.executor.Executor; import org.finos.legend.engine.persistence.components.ingestmode.IngestMode; @@ -28,8 +24,6 @@ import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition; import org.finos.legend.engine.persistence.components.logicalplan.datasets.DerivedDataset; import org.finos.legend.engine.persistence.components.logicalplan.datasets.Field; -import org.finos.legend.engine.persistence.components.logicalplan.datasets.Selection; -import org.finos.legend.engine.persistence.components.logicalplan.values.StringValue; import org.finos.legend.engine.persistence.components.planner.PlannerOptions; import org.finos.legend.engine.persistence.components.relational.CaseConversion; import org.finos.legend.engine.persistence.components.relational.SqlPlan; @@ -38,19 +32,13 @@ import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcConnection; import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcHelper; import org.finos.legend.engine.persistence.components.relational.postgres.PostgresSink; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; -import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; -import org.finos.legend.engine.persistence.components.transformer.Transformer; -import org.finos.legend.engine.persistence.components.util.MetadataDataset; -import org.finos.legend.engine.persistence.components.util.MetadataUtils; import org.finos.legend.engine.persistence.components.util.SchemaEvolutionCapability; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.postgresql.util.PGobject; import java.time.Clock; import java.time.ZoneOffset; @@ -58,7 +46,6 @@ import java.util.*; import java.util.stream.Collectors; -import static org.finos.legend.engine.persistence.components.util.MetadataUtils.BATCH_SOURCE_INFO_STAGING_FILTERS; import static org.junit.Assume.assumeTrue; public class BaseTest diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java index 0f485d81347..7f3b063a54b 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/e2e/unitemporal/UnitemporalDeltaTest.java @@ -194,8 +194,8 @@ void testMilestoningWithOptimizationFilters() throws Exception .dateTimeInName(batchTimeInName) .dateTimeOutName(batchTimeOutName) .build()) - .addOptimizationFilters(OptimizationFilter.of(expiryDateName, expiryDateName + "_lower", expiryDateName + "_upper")) - .addOptimizationFilters(OptimizationFilter.of(idName, idName + "_lower", idName + "_upper")) + .addOptimizationFilters(OptimizationFilter.of(expiryDateName)) + .addOptimizationFilters(OptimizationFilter.of(idName)) .build(); PlannerOptions options = PlannerOptions.builder().cleanupStagingData(false).collectStatistics(true).build(); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java index fc2921abdfa..dce8fa1764d 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-postgres/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/UnitemporalDeltaBatchIdBasedTest.java @@ -241,7 +241,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe String expectedMilestoneQuery = "UPDATE \"mydb\".\"main\" as sink " + "SET \"batch_id_out\" = (SELECT COALESCE(MAX(batch_metadata.\"table_batch_id\"),0)+1 FROM batch_metadata as batch_metadata " + "WHERE UPPER(batch_metadata.\"table_name\") = 'MAIN')-1 WHERE " + - "(sink.\"batch_id_out\" = 999999999) AND ((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')) " + + "(sink.\"batch_id_out\" = 999999999) AND ((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')) " + "AND (EXISTS (SELECT * FROM \"mydb\".\"staging\" as stage WHERE ((sink.\"id\" = stage.\"id\") " + "AND (sink.\"name\" = stage.\"name\")) AND (sink.\"digest\" <> stage.\"digest\")))"; @@ -252,7 +252,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFilters(GeneratorRe "WHERE UPPER(batch_metadata.\"table_name\") = 'MAIN'),999999999 FROM \"mydb\".\"staging\" as stage " + "WHERE NOT (EXISTS (SELECT * FROM \"mydb\".\"main\" as sink WHERE (sink.\"batch_id_out\" = 999999999) AND " + "(sink.\"digest\" = stage.\"digest\") AND ((sink.\"id\" = stage.\"id\") AND (sink.\"name\" = stage.\"name\")) AND " + - "((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')))))"; + "((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')))))"; Assertions.assertEquals(PostgresTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(PostgresTestArtifacts.expectedMetadataTableCreateQuery, preActionsSql.get(1)); @@ -272,7 +272,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull String expectedMilestoneQuery = "UPDATE \"mydb\".\"main\" as sink " + "SET \"batch_id_out\" = (SELECT COALESCE(MAX(batch_metadata.\"table_batch_id\"),0)+1 FROM batch_metadata as batch_metadata " + "WHERE UPPER(batch_metadata.\"table_name\") = 'MAIN')-1 WHERE " + - "(sink.\"batch_id_out\" = 999999999) AND (((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')) OR (sink.\"id\" IS NULL)) " + + "(sink.\"batch_id_out\" = 999999999) AND (((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')) OR (sink.\"id\" IS NULL)) " + "AND (EXISTS (SELECT * FROM \"mydb\".\"staging\" as stage WHERE ((sink.\"id\" = stage.\"id\") " + "AND (sink.\"name\" = stage.\"name\")) AND (sink.\"digest\" <> stage.\"digest\")))"; @@ -283,7 +283,7 @@ public void verifyUnitemporalDeltaNoDeleteIndWithOptimizationFiltersIncludesNull "WHERE UPPER(batch_metadata.\"table_name\") = 'MAIN'),999999999 FROM \"mydb\".\"staging\" as stage " + "WHERE NOT (EXISTS (SELECT * FROM \"mydb\".\"main\" as sink WHERE (sink.\"batch_id_out\" = 999999999) AND " + "(sink.\"digest\" = stage.\"digest\") AND ((sink.\"id\" = stage.\"id\") AND (sink.\"name\" = stage.\"name\")) AND " + - "(((sink.\"id\" >= '{ID_LOWER_BOUND}') AND (sink.\"id\" <= '{ID_UPPER_BOUND}')) OR (sink.\"id\" IS NULL)))))"; + "(((sink.\"id\" >= '{id_legend_persistence_lower}') AND (sink.\"id\" <= '{id_legend_persistence_upper}')) OR (sink.\"id\" IS NULL)))))"; Assertions.assertEquals(PostgresTestArtifacts.expectedMainTableBatchIdBasedCreateQuery, preActionsSql.get(0)); Assertions.assertEquals(PostgresTestArtifacts.expectedMetadataTableCreateQuery, preActionsSql.get(1)); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/pom.xml index e61bbf9003c..3c488e882ba 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -88,7 +88,7 @@ net.snowflake snowflake-jdbc 3.13.19 - runtime + provided diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java index 9aba3577dce..03be1c88281 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/SnowflakeSink.java @@ -28,7 +28,9 @@ import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanFactory; import org.finos.legend.engine.persistence.components.logicalplan.datasets.ClusterKey; import org.finos.legend.engine.persistence.components.logicalplan.datasets.DataType; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetAdditionalProperties; import org.finos.legend.engine.persistence.components.logicalplan.datasets.Field; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.FunctionalDataset; import org.finos.legend.engine.persistence.components.logicalplan.datasets.SchemaDefinition; import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetAdditionalProperties; import org.finos.legend.engine.persistence.components.logicalplan.datasets.StagedFilesDataset; @@ -60,7 +62,7 @@ import org.finos.legend.engine.persistence.components.relational.api.utils.IngestionUtils; import org.finos.legend.engine.persistence.components.relational.executor.RelationalExecutor; import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcConnection; -import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcHelper; +import org.finos.legend.engine.persistence.components.relational.snowflake.jdbc.SnowflakeJdbcHelper; import org.finos.legend.engine.persistence.components.relational.snowflake.logicalplan.datasets.SnowflakeStagedFilesDatasetProperties; import org.finos.legend.engine.persistence.components.relational.snowflake.logicalplan.datasets.StandardFileFormat; import org.finos.legend.engine.persistence.components.relational.snowflake.optmizer.LowerCaseOptimizer; @@ -71,6 +73,10 @@ import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.BatchEndTimestampVisitor; import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.CastFunctionVisitor; import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.ClusterKeyVisitor; +import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.CopyVisitor; +import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.DatasetAdditionalPropertiesVisitor; +import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.DigestUdfVisitor; +import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.FunctionalDatasetVisitor; import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.MetadataFileNameFieldVisitor; import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.MetadataRowNumberFieldVisitor; import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.SQLCreateVisitor; @@ -86,13 +92,14 @@ import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.StagedFilesSelectionVisitor; import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.ToArrayFunctionVisitor; import org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor.TryCastFunctionVisitor; -import org.finos.legend.engine.persistence.components.relational.sql.TabularData; +import org.finos.legend.engine.persistence.components.executor.TabularData; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils; import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; import org.finos.legend.engine.persistence.components.transformer.Transformer; import org.finos.legend.engine.persistence.components.util.Capability; +import org.finos.legend.engine.persistence.components.util.QueryStatsLogicalPlanUtils; import org.finos.legend.engine.persistence.components.util.PlaceholderValue; import org.finos.legend.engine.persistence.components.util.ValidationCategory; import org.slf4j.Logger; @@ -189,6 +196,7 @@ public class SnowflakeSink extends AnsiSqlSink logicalPlanVisitorByClass.put(MetadataFileNameField.class, new MetadataFileNameFieldVisitor()); logicalPlanVisitorByClass.put(MetadataRowNumberField.class, new MetadataRowNumberFieldVisitor()); logicalPlanVisitorByClass.put(ToArrayFunction.class, new ToArrayFunctionVisitor()); + logicalPlanVisitorByClass.put(FunctionalDataset.class, new FunctionalDatasetVisitor()); LOGICAL_PLAN_VISITOR_BY_CLASS = Collections.unmodifiableMap(logicalPlanVisitorByClass); @@ -263,7 +271,7 @@ public Executor getRelationalExecutor(RelationalCo if (relationalConnection instanceof JdbcConnection) { JdbcConnection jdbcConnection = (JdbcConnection) relationalConnection; - return new RelationalExecutor(this, JdbcHelper.of(jdbcConnection.connection())); + return new RelationalExecutor(this, SnowflakeJdbcHelper.of(jdbcConnection.connection())); } else { @@ -335,7 +343,7 @@ private List performDryRunWithValidationMode(Datasets datasets, Execu if (!results.isEmpty()) { - List> resultSets = results.get(0).getData(); + List> resultSets = results.get(0).data(); for (Map row : resultSets) { Map errorDetails = buildErrorDetails(getString(row, FILE_WITH_ERROR), getString(row, COLUMN_NAME), getLong(row, ROW_NUMBER)); @@ -482,7 +490,7 @@ private List performDryRunWithValidationQueries(Datasets datasets, Ex List results = executor.executePhysicalPlanAndGetResults(pair.getTwo()); if (!results.isEmpty()) { - List> resultSets = results.get(0).getData(); + List> resultSets = results.get(0).data(); for (Map row : resultSets) { // This loop will only be executed once as there is always only one element in the set @@ -503,7 +511,8 @@ private List performDryRunWithValidationQueries(Datasets datasets, Ex public IngestorResult performBulkLoad(Datasets datasets, Executor executor, SqlPlan ingestSqlPlan, Map statisticsSqlPlan, Map placeHolderKeyValues, Clock executionTimestampClock) { List results = executor.executePhysicalPlanAndGetResults(ingestSqlPlan, placeHolderKeyValues); - List> resultSets = results.get(0).getData(); + TabularData resultData = results.get(0); + List> resultSets = resultData.data(); List dataFilePathsWithErrors = new ArrayList<>(); long totalFilesLoaded = 0; @@ -546,6 +555,7 @@ public IngestorResult performBulkLoad(Datasets datasets, Executor appendLoadQueryStats(executor, stats, queryId)); IngestorResult.Builder resultBuilder = IngestorResult.builder() .updatedDatasets(datasets) @@ -592,4 +602,36 @@ private String getErrorMessage(Map row) throw new JsonReadOrWriteException(e.getMessage(), e); } } + + private void appendLoadQueryStats(Executor executor, Map stats, String queryId) + { + try + { + RelationalTransformer transformer = new RelationalTransformer(SnowflakeSink.get()); + SqlPlan physicalPlanForQueryOperatorStats = transformer.generatePhysicalPlan(QueryStatsLogicalPlanUtils.getLogicalPlanForQueryOperatorStats()); + HashMap queryIdPlaceHolder = new HashMap<>(); + queryIdPlaceHolder.put(QueryStatsLogicalPlanUtils.QUERY_ID_PARAMETER, PlaceholderValue.builder().value(queryId).isSensitive(false).build()); + List queryOperatorStats = executor.executePhysicalPlanAndGetResults(physicalPlanForQueryOperatorStats, queryIdPlaceHolder); + if (!queryOperatorStats.isEmpty()) + { + List> queryOperatorStatsResults = queryOperatorStats.get(0).data(); + queryOperatorStatsResults.forEach(queryStats -> + { + switch ((String) queryStats.get(QueryStatsLogicalPlanUtils.OPERATOR_TYPE_ALIAS)) + { + case QueryStatsLogicalPlanUtils.EXTERNAL_SCAN_STAGE: + stats.put(StatisticName.INPUT_FILES_BYTES_SCANNED, queryStats.get(QueryStatsLogicalPlanUtils.EXTERNAL_BYTES_SCANNED_ALIAS)); + break; + case QueryStatsLogicalPlanUtils.INSERT_STAGE: + stats.put(StatisticName.INCOMING_RECORD_COUNT, queryStats.get(QueryStatsLogicalPlanUtils.INPUT_ROWS_ALIAS)); + break; + } + }); + } + } + catch (Exception e) + { + LOGGER.error(String.format("Error extracting query stats for query id: [%s].", queryId), e); + } + } } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/jdbc/SnowflakeJdbcHelper.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/jdbc/SnowflakeJdbcHelper.java new file mode 100644 index 00000000000..a776eec03b4 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/jdbc/SnowflakeJdbcHelper.java @@ -0,0 +1,40 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.relational.snowflake.jdbc; + +import org.finos.legend.engine.persistence.components.executor.RelationalTransactionManager; +import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcHelper; + +import java.sql.Connection; +import java.sql.SQLException; + +public class SnowflakeJdbcHelper extends JdbcHelper +{ + private SnowflakeJdbcHelper(Connection connection) + { + super(connection); + } + + public static SnowflakeJdbcHelper of(Connection connection) + { + return new SnowflakeJdbcHelper(connection); + } + + @Override + protected RelationalTransactionManager intializeTransactionManager(Connection connection) throws SQLException + { + return new SnowflakeJdbcTransactionManager(connection); + } +} diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/jdbc/SnowflakeJdbcTransactionManager.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/jdbc/SnowflakeJdbcTransactionManager.java new file mode 100644 index 00000000000..f9afd5f84b2 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/jdbc/SnowflakeJdbcTransactionManager.java @@ -0,0 +1,73 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.relational.snowflake.jdbc; + +import net.snowflake.client.jdbc.SnowflakeResultSet; +import org.finos.legend.engine.persistence.components.executor.TabularData; +import org.finos.legend.engine.persistence.components.relational.jdbc.JdbcTransactionManager; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class SnowflakeJdbcTransactionManager extends JdbcTransactionManager +{ + public SnowflakeJdbcTransactionManager(Connection connection) throws SQLException + { + super(connection); + } + + public TabularData convertResultSetToTabularData(String sql) throws SQLException + { + List> resultList = new ArrayList<>(); + Optional queryId; + try (ResultSet resultSet = this.statement.executeQuery(sql)) + { + while (resultSet.next()) + { + extractResults(resultList, resultSet); + } + queryId = Optional.ofNullable(resultSet.unwrap(SnowflakeResultSet.class).getQueryID()); + } + return TabularData.builder() + .addAllData(resultList) + .queryId(queryId) + .build(); + } + + public TabularData convertResultSetToTabularData(String sql, int rows) throws SQLException + { + List> resultList = new ArrayList<>(); + Optional queryId; + try (ResultSet resultSet = this.statement.executeQuery(sql)) + { + int iter = 0; + while (resultSet.next() && iter < rows) + { + iter++; + extractResults(resultList, resultSet); + } + queryId = Optional.ofNullable(resultSet.unwrap(SnowflakeResultSet.class).getQueryID()); + } + return TabularData.builder() + .addAllData(resultList) + .queryId(queryId) + .build(); + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sql/visitor/AlterVisitor.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sql/visitor/AlterVisitor.java index 0c68da2e82d..a4f2ebc970d 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sql/visitor/AlterVisitor.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sql/visitor/AlterVisitor.java @@ -14,15 +14,22 @@ package org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetAdditionalProperties; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.TableOrigin; import org.finos.legend.engine.persistence.components.logicalplan.operations.Alter; import org.finos.legend.engine.persistence.components.optimizer.Optimizer; import org.finos.legend.engine.persistence.components.physicalplan.PhysicalPlanNode; import org.finos.legend.engine.persistence.components.relational.snowflake.sqldom.schemaops.statements.AlterTable; +import org.finos.legend.engine.persistence.components.relational.snowflake.sqldom.tabletypes.IcebergTableType; import org.finos.legend.engine.persistence.components.relational.sqldom.common.AlterOperation; +import org.finos.legend.engine.persistence.components.relational.sqldom.tabletypes.TableType; import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; import org.finos.legend.engine.persistence.components.transformer.VisitorContext; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; +import java.util.Optional; public class AlterVisitor implements LogicalPlanVisitor { @@ -30,7 +37,19 @@ public class AlterVisitor implements LogicalPlanVisitor @Override public VisitorResult visit(PhysicalPlanNode prev, Alter current, VisitorContext context) { - AlterTable alterTable = new AlterTable(AlterOperation.valueOf(current.operation().name())); + List types = new ArrayList<>(); + Optional datasetAdditionalProperties = current.dataset().datasetAdditionalProperties(); + if (datasetAdditionalProperties.isPresent()) + { + if (datasetAdditionalProperties.get().tableOrigin().isPresent()) + { + if (datasetAdditionalProperties.get().tableOrigin().get().equals(TableOrigin.ICEBERG)) + { + types.add(new IcebergTableType()); + } + } + } + AlterTable alterTable = new AlterTable(AlterOperation.valueOf(current.operation().name()), types); for (Optimizer optimizer : context.optimizers()) { alterTable = (AlterTable) optimizer.optimize(alterTable); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sql/visitor/FunctionalDatasetVisitor.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sql/visitor/FunctionalDatasetVisitor.java new file mode 100644 index 00000000000..07154d04142 --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sql/visitor/FunctionalDatasetVisitor.java @@ -0,0 +1,48 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.relational.snowflake.sql.visitor; + +import java.util.ArrayList; +import java.util.List; +import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlanNode; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.FunctionalDataset; +import org.finos.legend.engine.persistence.components.physicalplan.PhysicalPlanNode; +import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.expresssions.table.TableFunction; +import org.finos.legend.engine.persistence.components.transformer.LogicalPlanVisitor; +import org.finos.legend.engine.persistence.components.transformer.VisitorContext; + +public class FunctionalDatasetVisitor implements LogicalPlanVisitor +{ + @Override + public VisitorResult visit(PhysicalPlanNode prev, FunctionalDataset current, VisitorContext context) + { + TableFunction tableFunction = new TableFunction( + current.database().orElse(null), + current.group().orElse(null), + current.name().orElseThrow(IllegalStateException::new), + new ArrayList<>(), + context.quoteIdentifier() + ); + + prev.push(tableFunction); + + if (current.value() != null) + { + List logicalPlanNodeList = new ArrayList<>(current.value()); + return new VisitorResult(tableFunction, logicalPlanNodeList); + } + return new VisitorResult(null); + } +} diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/statements/AlterTable.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/statements/AlterTable.java index 6d24a2f7623..2a3978a10a7 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/statements/AlterTable.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/statements/AlterTable.java @@ -15,12 +15,17 @@ package org.finos.legend.engine.persistence.components.relational.snowflake.sqldom.schemaops.statements; import org.finos.legend.engine.persistence.components.relational.sqldom.SqlDomException; +import org.finos.legend.engine.persistence.components.relational.sqldom.SqlGen; import org.finos.legend.engine.persistence.components.relational.sqldom.common.AlterOperation; import org.finos.legend.engine.persistence.components.relational.sqldom.common.Clause; import org.finos.legend.engine.persistence.components.relational.sqldom.constraints.column.NotNullColumnConstraint; import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.Column; import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.expresssions.table.Table; import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.statements.DDLStatement; +import org.finos.legend.engine.persistence.components.relational.sqldom.tabletypes.TableType; + +import java.util.ArrayList; +import java.util.List; import static org.finos.legend.engine.persistence.components.relational.sqldom.common.Clause.COLUMN; import static org.finos.legend.engine.persistence.components.relational.sqldom.common.Clause.DROP; @@ -31,10 +36,12 @@ public class AlterTable implements DDLStatement private final AlterOperation operation; private Table table; private Column columnToAlter; + private final List types; - public AlterTable(AlterOperation operation) + public AlterTable(AlterOperation operation, List types) { this.operation = operation; + this.types = types; } public Table getTable() @@ -55,6 +62,9 @@ public void genSql(StringBuilder builder) throws SqlDomException validate(); builder.append(Clause.ALTER.get()); + // Table Type + SqlGen.genSqlList(builder, types, WHITE_SPACE, WHITE_SPACE); + builder.append(WHITE_SPACE + Clause.TABLE.get()); // Table name @@ -103,6 +113,10 @@ public void push(Object node) { table = (Table) node; } + else if (node instanceof TableType) + { + types.add((TableType) node); + } else if (node instanceof Column) { columnToAlter = (Column) node; diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/values/StagedFilesField.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/values/StagedFilesField.java index 79b73a435d5..10d76f9fdf2 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/values/StagedFilesField.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/values/StagedFilesField.java @@ -16,6 +16,7 @@ import org.finos.legend.engine.persistence.components.relational.sqldom.SqlDomException; import org.finos.legend.engine.persistence.components.relational.sqldom.schemaops.values.Value; +import org.finos.legend.engine.persistence.components.relational.sqldom.utils.SqlGenUtils; import org.finos.legend.engine.persistence.components.relational.sqldom.utils.StringUtils; public class StagedFilesField extends Value @@ -63,7 +64,7 @@ public void genSqlWithoutAlias(StringBuilder builder) throws SqlDomException builder.append(String.format("$%d", columnNumber)); if (StringUtils.notEmpty(elementPath)) { - builder.append(":").append(elementPath); + builder.append(":").append(SqlGenUtils.getQuotedField(elementPath, getQuoteIdentifier())); } } diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/util/QueryStatsLogicalPlanUtils.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/util/QueryStatsLogicalPlanUtils.java new file mode 100644 index 00000000000..cb3a2e0a71f --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/main/java/org/finos/legend/engine/persistence/components/util/QueryStatsLogicalPlanUtils.java @@ -0,0 +1,73 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.util; + +import org.finos.legend.engine.persistence.components.logicalplan.LogicalPlan; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.FunctionalDataset; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.Selection; +import org.finos.legend.engine.persistence.components.logicalplan.values.FieldValue; +import org.finos.legend.engine.persistence.components.logicalplan.values.FunctionImpl; +import org.finos.legend.engine.persistence.components.logicalplan.values.FunctionName; +import org.finos.legend.engine.persistence.components.logicalplan.values.StringValue; + +public class QueryStatsLogicalPlanUtils +{ + public static final String QUERY_OPERATOR_STATS_FUNCTION = "GET_QUERY_OPERATOR_STATS"; + public static final String QUERY_ID_PARAMETER = "{QUERY_ID}"; + public static final String OPERATOR_TYPE = "OPERATOR_TYPE"; + public static final String OPERATOR_STATISTICS = "OPERATOR_STATISTICS"; + + public static final String OPERATOR_TYPE_ALIAS = "operatorType"; + public static final String EXTERNAL_BYTES_SCANNED_ALIAS = "externalBytesScanned"; + public static final String INPUT_ROWS_ALIAS = "inputRows"; + + public static final String EXTERNAL_BYTES_SCANNED_PATH = "io.external_bytes_scanned"; + public static final String INPUT_ROWS_PATH = "input_rows"; + + public static final String EXTERNAL_SCAN_STAGE = "ExternalScan"; + public static final String INSERT_STAGE = "Insert"; + + private QueryStatsLogicalPlanUtils() + { + } + + public static LogicalPlan getLogicalPlanForQueryOperatorStats() + { + return LogicalPlan.builder() + .addOps(Selection.builder() + .addFields(FieldValue.builder().fieldName(OPERATOR_TYPE).alias(OPERATOR_TYPE_ALIAS).build()) + .addFields(FunctionImpl.builder() + .functionName(FunctionName.JSON_EXTRACT_PATH_TEXT) + .addValue(FieldValue.builder().fieldName(OPERATOR_STATISTICS).build()) + .addValue(StringValue.of(EXTERNAL_BYTES_SCANNED_PATH)) + .alias(EXTERNAL_BYTES_SCANNED_ALIAS) + .build() + ) + .addFields(FunctionImpl.builder() + .functionName(FunctionName.JSON_EXTRACT_PATH_TEXT) + .addValue(FieldValue.builder().fieldName(OPERATOR_STATISTICS).build()) + .addValue(StringValue.of(INPUT_ROWS_PATH)) + .alias(INPUT_ROWS_ALIAS) + .build() + ) + .source(FunctionalDataset + .builder() + .name(QUERY_OPERATOR_STATS_FUNCTION) + .addValue(StringValue.of(QUERY_ID_PARAMETER)) + .build()) + .build()) + .build(); + } +} diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BulkLoadTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BulkLoadTest.java index 25106f3948d..52255922730 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BulkLoadTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/ingestmode/BulkLoadTest.java @@ -85,6 +85,20 @@ public class BulkLoadTest .columnNumber(6) .build(); + private static Field col6 = Field.builder() + .name("col_string") + .type(FieldType.of(DataType.STRING, Optional.empty(), Optional.empty())) + .columnNumber(1) + .elementPath("col_string") + .build(); + + private static Field col7 = Field.builder() + .name("col_datetime") + .type(FieldType.of(DataType.DATETIME, Optional.empty(), Optional.empty())) + .columnNumber(1) + .elementPath("col_datetime") + .build(); + private static Field col1NonNullable = Field.builder() .name("col_int") .type(FieldType.of(DataType.INT, Optional.empty(), Optional.empty())) @@ -880,4 +894,66 @@ public void testBulkLoadWithDigestAndTypeConversionUdfsAndcolumnTransformationUd Assertions.assertNull(statsSql.get(ROWS_UPDATED)); Assertions.assertEquals("SELECT COUNT(*) as \"rowsInserted\" FROM \"my_db\".\"my_name\" as my_alias WHERE my_alias.\"batch_id\" = (SELECT COALESCE(MAX(batch_metadata.\"table_batch_id\"),0)+1 FROM batch_metadata as batch_metadata WHERE UPPER(batch_metadata.\"table_name\") = 'MY_NAME')", statsSql.get(ROWS_INSERTED)); } + + @Test + public void testBulkLoadWithElementPath() + { + BulkLoad bulkLoad = BulkLoad.builder() + .batchIdField("batch_id") + .digestGenStrategy(UDFBasedDigestGenStrategy.builder() + .digestField("digest") + .digestUdfName("LAKEHOUSE_UDF") + .columnNameValueConcatUdfName("COLUMN_STRING_UDF") + .build()) + .auditing(DateTimeAuditing.builder().dateTimeField(APPEND_TIME).build()) + .build(); + + Dataset stagedFilesDataset = StagedFilesDataset.builder() + .stagedFilesDatasetProperties( + SnowflakeStagedFilesDatasetProperties.builder() + .location("my_location") + .fileFormat(UserDefinedFileFormat.of("my_file_format")) + .addAllFilePaths(filesList).build()) + .schema(SchemaDefinition.builder().addAllFields(Arrays.asList(col6, col7)).build()) + .build(); + + Dataset mainDataset = DatasetDefinition.builder() + .database("my_db").name("my_name").alias("my_alias") + .schema(SchemaDefinition.builder().build()) + .build(); + + RelationalGenerator generator = RelationalGenerator.builder() + .ingestMode(bulkLoad) + .relationalSink(SnowflakeSink.get()) + .collectStatistics(true) + .executionTimestampClock(fixedClock_2000_01_01) + .ingestRequestId("task123") + .ingestRunId(ingestRunId) + .build(); + + GeneratorResult operations = generator.generateOperations(Datasets.of(mainDataset, stagedFilesDataset)); + + List preActionsSql = operations.preActionsSql(); + List ingestSql = operations.ingestSql(); + Map statsSql = operations.postIngestStatisticsSql(); + + String expectedCreateTableSql = "CREATE TABLE IF NOT EXISTS \"my_db\".\"my_name\"(\"col_string\" VARCHAR,\"col_datetime\" DATETIME,\"digest\" VARCHAR,\"batch_id\" INTEGER,\"append_time\" DATETIME)"; + + String expectedIngestSql = "COPY INTO \"my_db\".\"my_name\" " + + "(\"col_string\", \"col_datetime\", \"digest\", \"batch_id\", \"append_time\") " + + "FROM (SELECT legend_persistence_stage.$1:\"col_string\" as \"col_string\",legend_persistence_stage.$1:\"col_datetime\" as \"col_datetime\"," + + "LAKEHOUSE_UDF(CONCAT(COLUMN_STRING_UDF('col_datetime',CAST(legend_persistence_stage.$1:\"col_datetime\" AS DATETIME)),COLUMN_STRING_UDF('col_string',CAST(legend_persistence_stage.$1:\"col_string\" AS VARCHAR))))," + + "(SELECT COALESCE(MAX(batch_metadata.\"table_batch_id\"),0)+1 FROM batch_metadata as batch_metadata WHERE UPPER(batch_metadata.\"table_name\") = 'MY_NAME'),'2000-01-01 00:00:00.000000' " + + "FROM my_location as legend_persistence_stage) " + + "FILES = ('/path/xyz/file1.csv', '/path/xyz/file2.csv') FILE_FORMAT = (FORMAT_NAME = 'my_file_format') ON_ERROR = 'ABORT_STATEMENT'"; + + Assertions.assertEquals(expectedCreateTableSql, preActionsSql.get(0)); + Assertions.assertEquals(expectedIngestSql, ingestSql.get(0)); + + Assertions.assertNull(statsSql.get(INCOMING_RECORD_COUNT)); + Assertions.assertNull(statsSql.get(ROWS_DELETED)); + Assertions.assertNull(statsSql.get(ROWS_TERMINATED)); + Assertions.assertNull(statsSql.get(ROWS_UPDATED)); + Assertions.assertEquals("SELECT COUNT(*) as \"rowsInserted\" FROM \"my_db\".\"my_name\" as my_alias WHERE my_alias.\"batch_id\" = (SELECT COALESCE(MAX(batch_metadata.\"table_batch_id\"),0)+1 FROM batch_metadata as batch_metadata WHERE UPPER(batch_metadata.\"table_name\") = 'MY_NAME')", statsSql.get(ROWS_INSERTED)); + } } \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/CopyStatementTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/CopyStatementTest.java index a10b0620bc5..db9f2c06fd9 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/CopyStatementTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/relational/snowflake/sqldom/schemaops/CopyStatementTest.java @@ -111,7 +111,7 @@ void testCopyStatementWithPatternAndFileFormatAndForceOption() throws SqlDomExce String expectedStr = "COPY INTO \"mydb\".\"mytable1\" " + "(\"field1\", \"field2\", \"field3\", \"field4\") " + "FROM " + - "(SELECT t.$1:field1 as \"field1\",t.$1:field2 as \"field2\",t.$1:field3 as \"field3\",t.$1:field4 as \"field4\" " + + "(SELECT t.$1:\"field1\" as \"field1\",t.$1:\"field2\" as \"field2\",t.$1:\"field3\" as \"field3\",t.$1:\"field4\" as \"field4\" " + "FROM @my_stage as t) " + "PATTERN = '(my_pattern1)|(my_pattern2)' " + "FILE_FORMAT = (FORMAT_NAME = 'my_file_format') " + diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/schemaevolution/SchemaEvolutionTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/schemaevolution/SchemaEvolutionTest.java index cbfa3b85d82..d3fd42d9882 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/schemaevolution/SchemaEvolutionTest.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/schemaevolution/SchemaEvolutionTest.java @@ -20,9 +20,11 @@ import org.finos.legend.engine.persistence.components.logicalplan.datasets.DataType; import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset; import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetAdditionalProperties; import org.finos.legend.engine.persistence.components.logicalplan.datasets.Field; import org.finos.legend.engine.persistence.components.logicalplan.datasets.FieldType; import org.finos.legend.engine.persistence.components.logicalplan.datasets.SchemaDefinition; +import org.finos.legend.engine.persistence.components.logicalplan.datasets.TableOrigin; import org.finos.legend.engine.persistence.components.relational.RelationalSink; import org.finos.legend.engine.persistence.components.relational.SqlPlan; import org.finos.legend.engine.persistence.components.relational.ansi.optimizer.UpperCaseOptimizer; @@ -256,6 +258,68 @@ void testSnapshotMilestoningWithImplicitDataTypeEvolutionAndLengthEvolution() Assertions.assertEquals(expectedAlterDecimalLength, sqlsForSchemaEvolution.get(0)); } + @Test + void testSnapshotMilestoningWithAddColumnAndIgnoreCase() + { + RelationalTransformer transformer = new RelationalTransformer(relationalSink, TransformOptions.builder().build()); + + Dataset mainTable = DatasetDefinition.builder() + .database(mainDbName).name(mainTableName).alias(mainTableAlias) + .schema(baseTableShortenedSchema) + .datasetAdditionalProperties(DatasetAdditionalProperties.builder().tableOrigin(TableOrigin.ICEBERG).build()) + .build(); + + Dataset stagingTable = DatasetDefinition.builder() + .database(stagingDbName).name(stagingTableName).alias(stagingTableAlias) + .schema(baseTableSchemaWithSomeColumnsInUpperCase) + .build(); + + NontemporalSnapshot ingestMode = NontemporalSnapshot.builder().auditing(NoAuditing.builder().build()).build(); + Set schemaEvolutionCapabilitySet = new HashSet<>(); + schemaEvolutionCapabilitySet.add(SchemaEvolutionCapability.ADD_COLUMN); + SchemaEvolution schemaEvolution = new SchemaEvolution(relationalSink, ingestMode, schemaEvolutionCapabilitySet, true); + + SchemaEvolutionResult result = schemaEvolution.buildLogicalPlanForSchemaEvolution(mainTable, stagingTable.schema()); + SqlPlan physicalPlanForSchemaEvolution = transformer.generatePhysicalPlan(result.logicalPlan()); + + // Use the planner utils to return the sql + List sqlsForSchemaEvolution = physicalPlanForSchemaEvolution.getSqlList(); + Assertions.assertEquals(1, sqlsForSchemaEvolution.size()); + String expectedSchemaEvolutionAddColumn = "ALTER ICEBERG TABLE \"mydb\".\"main\" ADD COLUMN \"biz_date\" DATE"; + Assertions.assertEquals(expectedSchemaEvolutionAddColumn, sqlsForSchemaEvolution.get(0)); + } + + @Test + void testSnapshotMilestoningWithAlterNullabilityAndUserCapability() + { + Dataset mainTable = DatasetDefinition.builder() + .database(mainDbName).name(mainTableName).alias(mainTableAlias) + .schema(baseTableSchemaWithNonNullableColumn) + .datasetAdditionalProperties(DatasetAdditionalProperties.builder().tableOrigin(TableOrigin.ICEBERG).build()) + .build(); + + Dataset stagingTable = DatasetDefinition.builder() + .database(stagingDbName).name(stagingTableName).alias(stagingTableAlias) + .schema(stagingTableNullableChange) + .build(); + + NontemporalSnapshot ingestMode = NontemporalSnapshot.builder().auditing(NoAuditing.builder().build()).build(); + Set schemaEvolutionCapabilitySet = new HashSet<>(); + schemaEvolutionCapabilitySet.add(SchemaEvolutionCapability.COLUMN_NULLABILITY_CHANGE); + SchemaEvolution schemaEvolution = new SchemaEvolution(relationalSink, ingestMode, schemaEvolutionCapabilitySet, false); + SchemaEvolutionResult result = schemaEvolution.buildLogicalPlanForSchemaEvolution(mainTable, stagingTable.schema()); + RelationalTransformer transformer = new RelationalTransformer(relationalSink); + SqlPlan physicalPlanForSchemaEvolution = transformer.generatePhysicalPlan(result.logicalPlan()); + + List sqlsForSchemaEvolution = physicalPlanForSchemaEvolution.getSqlList(); + + Assertions.assertEquals(2, sqlsForSchemaEvolution.size()); + String expectedSchemaImplicitNullabilityChange = "ALTER ICEBERG TABLE \"mydb\".\"main\" ALTER COLUMN \"amount\" DROP NOT NULL"; + String expectedSchemaNullabilityChange = "ALTER ICEBERG TABLE \"mydb\".\"main\" ALTER COLUMN \"biz_date\" DROP NOT NULL"; + Assertions.assertEquals(expectedSchemaImplicitNullabilityChange, sqlsForSchemaEvolution.get(0)); + Assertions.assertEquals(expectedSchemaNullabilityChange, sqlsForSchemaEvolution.get(1)); + } + // Data type change required in main table column (float --> double) and data_type_conversion capability allowed @Test void testSnapshotMilestoningWithNonBreakingDataTypeEvolution() diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/util/QueryStatsLogicalPlanUtilsTest.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/util/QueryStatsLogicalPlanUtilsTest.java new file mode 100644 index 00000000000..15f068c0a9e --- /dev/null +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-snowflake/src/test/java/org/finos/legend/engine/persistence/components/util/QueryStatsLogicalPlanUtilsTest.java @@ -0,0 +1,35 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.persistence.components.util; + +import java.util.List; +import org.finos.legend.engine.persistence.components.relational.SqlPlan; +import org.finos.legend.engine.persistence.components.relational.snowflake.SnowflakeSink; +import org.finos.legend.engine.persistence.components.relational.transformer.RelationalTransformer; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class QueryStatsLogicalPlanUtilsTest +{ + @Test + public void testLogicalPlanForQueryOperatorStats() + { + RelationalTransformer transformer = new RelationalTransformer(SnowflakeSink.get()); + SqlPlan physicalPlanForQueryOperatorStats = transformer.generatePhysicalPlan(QueryStatsLogicalPlanUtils.getLogicalPlanForQueryOperatorStats()); + List list = physicalPlanForQueryOperatorStats.getSqlList(); + String expectedQuery = "SELECT \"OPERATOR_TYPE\" as \"operatorType\",JSON_EXTRACT_PATH_TEXT(\"OPERATOR_STATISTICS\",'io.external_bytes_scanned') as \"externalBytesScanned\",JSON_EXTRACT_PATH_TEXT(\"OPERATOR_STATISTICS\",'input_rows') as \"inputRows\" FROM TABLE(GET_QUERY_OPERATOR_STATS('{QUERY_ID}'))"; + Assertions.assertEquals(expectedQuery, list.get(0)); + } +} \ No newline at end of file diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/pom.xml index 06e50dda79c..192fbb89603 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/pom.xml @@ -15,7 +15,7 @@ org.finos.legend.engine legend-engine-xt-persistence-component - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/scenarios/UnitemporalDeltaBatchIdBasedScenarios.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/scenarios/UnitemporalDeltaBatchIdBasedScenarios.java index d8cb52f53e6..e3eac4cccb0 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/scenarios/UnitemporalDeltaBatchIdBasedScenarios.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/scenarios/UnitemporalDeltaBatchIdBasedScenarios.java @@ -104,7 +104,7 @@ public TestScenario BATCH_ID_BASED__WITH_DEL_IND__NO_DEDUP__ALL_VERSION() public TestScenario BATCH_ID_BASED__NO_DEL_IND__WITH_OPTIMIZATION_FILTERS() { - OptimizationFilter filter = OptimizationFilter.of("id", "{ID_LOWER_BOUND}", "{ID_UPPER_BOUND}"); + OptimizationFilter filter = OptimizationFilter.of("id"); UnitemporalDelta ingestMode = UnitemporalDelta.builder() .digestField(digestField) .transactionMilestoning(BatchId.builder() @@ -118,7 +118,7 @@ public TestScenario BATCH_ID_BASED__NO_DEL_IND__WITH_OPTIMIZATION_FILTERS() public TestScenario BATCH_ID_BASED__NO_DEL_IND__WITH_OPTIMIZATION_FILTERS__INCLUDES_NULL_VALUES() { - OptimizationFilter filter = OptimizationFilter.of("id", "{ID_LOWER_BOUND}", "{ID_UPPER_BOUND}").withIncludesNullValues(true); + OptimizationFilter filter = OptimizationFilter.of("id").withIncludesNullValues(true); UnitemporalDelta ingestMode = UnitemporalDelta.builder() .digestField(digestField) .transactionMilestoning(BatchId.builder() @@ -132,7 +132,7 @@ public TestScenario BATCH_ID_BASED__NO_DEL_IND__WITH_OPTIMIZATION_FILTERS__INCLU public TestScenario BATCH_ID_BASED__NO_DEL_IND__WITH_MISSING_OPTIMIZATION_FILTER() { - OptimizationFilter filter = OptimizationFilter.of("unknown_column", "{ID_LOWER_BOUND}", "{ID_UPPER_BOUND}"); + OptimizationFilter filter = OptimizationFilter.of("unknown_column"); UnitemporalDelta ingestMode = UnitemporalDelta.builder() .digestField(digestField) .transactionMilestoning(BatchId.builder() @@ -146,7 +146,7 @@ public TestScenario BATCH_ID_BASED__NO_DEL_IND__WITH_MISSING_OPTIMIZATION_FILTER public TestScenario BATCH_ID_BASED__NO_DEL_IND__WITH_OPTIMIZATION_FILTER_UNSUPPORTED_DATATYPE() { - OptimizationFilter filter = OptimizationFilter.of("name", "{NAME_LOWER_BOUND}", "{NAME_UPPER_BOUND}"); + OptimizationFilter filter = OptimizationFilter.of("name"); UnitemporalDelta ingestMode = UnitemporalDelta.builder() .digestField(digestField) .transactionMilestoning(BatchId.builder() diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/testcases/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTestCases.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/testcases/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTestCases.java index 7e8f2dc9270..0fd14049c7a 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/testcases/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTestCases.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/legend-engine-xt-persistence-component-relational-test/src/test/java/org/finos/legend/engine/persistence/components/testcases/ingestmode/bitemporal/BitemporalDeltaSourceSpecifiesFromTestCases.java @@ -90,6 +90,7 @@ void testBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplits() .relationalSink(getRelationalSink()) .executionTimestampClock(fixedClock_2000_01_01) .collectStatistics(true) + .ingestRunId(ingestRunId) .build(); List operations = generator.generateOperationsWithDataSplits(scenario.getDatasets(), dataSplitRangesOneToTwo); verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplits(operations, dataSplitRangesOneToTwo); @@ -155,6 +156,7 @@ void testBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDuplicates( .relationalSink(getRelationalSink()) .executionTimestampClock(fixedClock_2000_01_01) .collectStatistics(true) + .ingestRunId(ingestRunId) .build(); List operations = generator.generateOperationsWithDataSplits(scenario.getDatasets(), dataSplitRangesOneToTwo); verifyBitemporalDeltaBatchIdBasedWithDeleteIndWithDataSplitsFilterDuplicates(operations, dataSplitRangesOneToTwo); diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/pom.xml index ef2a769e64a..fc1a3524f3f 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-component/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-component/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/pom.xml index afd7420d6db..3cd512cb71c 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/src/main/java/org/finos/legend/engine/language/pure/dsl/persistence/compiler/toPureGraph/PersistenceCompilerExtension.java b/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/src/main/java/org/finos/legend/engine/language/pure/dsl/persistence/compiler/toPureGraph/PersistenceCompilerExtension.java index cfdb81483e4..2bbf45e5b86 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/src/main/java/org/finos/legend/engine/language/pure/dsl/persistence/compiler/toPureGraph/PersistenceCompilerExtension.java +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-grammar/src/main/java/org/finos/legend/engine/language/pure/dsl/persistence/compiler/toPureGraph/PersistenceCompilerExtension.java @@ -61,7 +61,6 @@ import java.util.Collections; import java.util.List; -import java.util.ServiceLoader; import static org.finos.legend.pure.generated.core_persistence_persistence_validation.Root_meta_pure_persistence_validation_validate_T_1__ValidationRuleSet_1__ValidationResult_1_; import static org.finos.legend.pure.generated.core_persistence_persistence_validations_rules.Root_meta_pure_persistence_validation_commonRules_Extension_MANY__ValidationRuleSet_1_; @@ -120,12 +119,6 @@ public Iterable> getExtraProcessors() purePersistenceContext._serviceParameters(ListIterate.collect(persistenceContext.serviceParameters, sp -> HelperPersistenceContextBuilder.buildServiceParameter(sp, context))); purePersistenceContext._sinkConnection(HelperPersistenceContextBuilder.buildConnection(persistenceContext.sinkConnection, context)); }, - (persistenceContext, context) -> - { - }, - (persistenceContext, context) -> - { - }, // use the final compiler pass to invoke validation extensions (persistenceContext, context) -> { diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-http-api/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-http-api/pom.xml index e527ae58912..20c260b4a73 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-http-api/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-protocol/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-protocol/pom.xml index e32725c2e2a..9bf4c40a5b1 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-protocol/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-pure/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-pure/pom.xml index 999ff23bb5a..29b767e71c4 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-pure/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-grammar/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-grammar/pom.xml index 960d5e5bb51..19e71b7a423 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-grammar/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-grammar/pom.xml @@ -3,7 +3,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-protocol/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-protocol/pom.xml index 2de680bc4f5..e892af2593b 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-protocol/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-protocol/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-pure/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-pure/pom.xml index 7091d644996..16ffa0844d2 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-pure/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-target-relational-pure/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/legend-engine-xt-persistence-test-runner/pom.xml b/legend-engine-xts-persistence/legend-engine-xt-persistence-test-runner/pom.xml index ba09ae62158..908708e39d3 100644 --- a/legend-engine-xts-persistence/legend-engine-xt-persistence-test-runner/pom.xml +++ b/legend-engine-xts-persistence/legend-engine-xt-persistence-test-runner/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-persistence - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-persistence/pom.xml b/legend-engine-xts-persistence/pom.xml index 0d3eef8b97d..bd5d139018d 100644 --- a/legend-engine-xts-persistence/pom.xml +++ b/legend-engine-xts-persistence/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-grammar/pom.xml b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-grammar/pom.xml index d9a72e54d94..a31cac7dc80 100644 --- a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-grammar/pom.xml +++ b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-protobuf - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-protobuf-grammar diff --git a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-http-api/pom.xml b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-http-api/pom.xml index 7ac0e41c4c3..4e1a5551bb4 100644 --- a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-http-api/pom.xml +++ b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-http-api/pom.xml @@ -4,7 +4,7 @@ org.finos.legend.engine legend-engine-xts-protobuf - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-protobuf-http-api diff --git a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-protocol/pom.xml b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-protocol/pom.xml index f929c44c799..acc1e0da155 100644 --- a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-protocol/pom.xml +++ b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-protobuf - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-protobuf-protocol diff --git a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-pure/pom.xml b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-pure/pom.xml index 8bf56039788..40a55c6898e 100644 --- a/legend-engine-xts-protobuf/legend-engine-xt-protobuf-pure/pom.xml +++ b/legend-engine-xts-protobuf/legend-engine-xt-protobuf-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-protobuf - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-protobuf/legend-engine-xt-protobuf/pom.xml b/legend-engine-xts-protobuf/legend-engine-xt-protobuf/pom.xml index f8d9c868869..1d4a28db18e 100644 --- a/legend-engine-xts-protobuf/legend-engine-xt-protobuf/pom.xml +++ b/legend-engine-xts-protobuf/legend-engine-xt-protobuf/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-protobuf - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -57,7 +57,7 @@ org.finos.legend.engine legend-engine-protocol-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT org.finos.legend.pure diff --git a/legend-engine-xts-protobuf/pom.xml b/legend-engine-xts-protobuf/pom.xml index 9bed4480c2a..dde97fa0a1f 100644 --- a/legend-engine-xts-protobuf/pom.xml +++ b/legend-engine-xts-protobuf/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation-pure/pom.xml b/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation-pure/pom.xml index 136c07c839a..7999b4f1bd6 100644 --- a/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation-pure/pom.xml +++ b/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-protocol-java-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-protocol-generation-pure diff --git a/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation/pom.xml b/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation/pom.xml index 26733958dc5..0c35fba13c5 100644 --- a/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation/pom.xml +++ b/legend-engine-xts-protocol-java-generation/legend-engine-protocol-generation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xts-protocol-java-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-protocol-generation diff --git a/legend-engine-xts-protocol-java-generation/pom.xml b/legend-engine-xts-protocol-java-generation/pom.xml index e9668cec35b..8f7a919cbc7 100644 --- a/legend-engine-xts-protocol-java-generation/pom.xml +++ b/legend-engine-xts-protocol-java-generation/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/pom.xml index 32df0070e24..6d11e82bf9d 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-PCT - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/src/main/resources/core_external_test_connection/pct_relational.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/src/main/resources/core_external_test_connection/pct_relational.pure index 595fe717a18..6564e970383 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/src/main/resources/core_external_test_connection/pct_relational.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-functions-relationalStore-PCT-pure/src/main/resources/core_external_test_connection/pct_relational.pure @@ -29,7 +29,7 @@ import meta::pure::metamodel::relation::*; import meta::relational::tests::pct::process::*; import meta::pure::test::pct::*; -function <> meta::relational::tests::pct::testAdapterForRelationalWithH2Execution(f:Function<{->X[o]}>[1]):X[o] +function <> {PCT.adapterName='H2'} meta::relational::tests::pct::testAdapterForRelationalWithH2Execution(f:Function<{->X[o]}>[1]):X[o] { meta::relational::tests::pct::testAdapterForRelationalExecution( $f, @@ -37,7 +37,7 @@ function <> meta::relational::tests::pct::testAdapterForRelationalW ) } -function <> meta::relational::tests::pct::testAdapterForRelationalWithDuckDBExecution(f:Function<{->X[o]}>[1]):X[o] +function <> {PCT.adapterName='DuckDB'} meta::relational::tests::pct::testAdapterForRelationalWithDuckDBExecution(f:Function<{->X[o]}>[1]):X[o] { meta::relational::tests::pct::testAdapterForRelationalExecution( $f, @@ -45,7 +45,7 @@ function <> meta::relational::tests::pct::testAdapterForRelationalW ) } -function <> meta::relational::tests::pct::testAdapterForRelationalWithPostgresExecution(f:Function<{->X[o]}>[1]):X[o] +function <> {PCT.adapterName='PostgreSQL'} meta::relational::tests::pct::testAdapterForRelationalWithPostgresExecution(f:Function<{->X[o]}>[1]):X[o] { meta::relational::tests::pct::testAdapterForRelationalExecution( $f, @@ -53,7 +53,7 @@ function <> meta::relational::tests::pct::testAdapterForRelationalW ) } -function <> meta::relational::tests::pct::testAdapterForRelationalWithSnowflakeExecution(f:Function<{->X[o]}>[1]):X[o] +function <> {PCT.adapterName='Snowflake'} meta::relational::tests::pct::testAdapterForRelationalWithSnowflakeExecution(f:Function<{->X[o]}>[1]):X[o] { meta::relational::tests::pct::testAdapterForRelationalExecution( $f, diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-PCT/pom.xml index f84b681a4a3..f4b766cc467 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-PCT - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -132,10 +132,6 @@ legend-engine-pure-runtime-java-extension-compiled-functions-unclassified - - org.finos.legend.engine - legend-engine-pure-runtime-java-extension-compiled-functions-relation - org.finos.legend.engine legend-engine-pure-runtime-java-extension-compiled-functions-relation @@ -164,7 +160,6 @@ org.finos.legend.engine legend-engine-xt-relationalStore-core-pure - runtime @@ -248,10 +243,6 @@ legend-pure-m2-dsl-diagram-grammar test - - org.finos.legend.engine - legend-engine-xt-relationalStore-core-pure - org.finos.legend.engine legend-engine-language-pure-compiler diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/pom.xml index af4aa179f2b..22c9d9a45a3 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-PCT - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/interpreted/natives/GetTestConnection.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/interpreted/natives/GetTestConnection.java index 22d782b0f29..91855fe7b22 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/interpreted/natives/GetTestConnection.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/interpreted/natives/GetTestConnection.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.list.ListIterable; import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; import org.eclipse.collections.impl.factory.Lists; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; @@ -48,7 +49,7 @@ public GetTestConnection(FunctionExecutionInterpreted functionExecution, ModelRe } @Override - public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, CoreInstance functionExpressionToUseInStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException { CoreInstance dbType = params.get(0).getValueForMetaPropertyToOne(M3Properties.values); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/pom.xml index b20d6c5d70d..c705f9bf3ae 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-PCT - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -44,7 +44,6 @@ - org.finos.legend.pure legend-pure-m4 @@ -53,7 +52,6 @@ org.finos.legend.pure legend-pure-m3-core - org.eclipse.collections eclipse-collections-api @@ -62,39 +60,27 @@ org.eclipse.collections eclipse-collections - junit junit - org.finos.legend.engine legend-engine-xt-relationalStore-executionPlan-connection - org.finos.legend.engine legend-engine-xt-relationalStore-grammar runtime - - - - org.finos.legend.engine - legend-engine-xt-relationalStore-protocol - - org.finos.legend.engine legend-engine-xt-relationalStore-protocol - org.finos.legend.engine legend-engine-test-framework runtime - diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/shared/GetTestConnectionShared.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/shared/GetTestConnectionShared.java index 3993c71ecf7..85262d53802 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/shared/GetTestConnectionShared.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-pure-runtime-java-extension-shared-functions-relationalStore-PCT/src/main/java/org/finos/legend/engine/pure/runtime/testConnection/shared/GetTestConnectionShared.java @@ -14,6 +14,7 @@ package org.finos.legend.engine.pure.runtime.testConnection.shared; +import org.eclipse.collections.api.factory.Stacks; import org.finos.legend.engine.plan.execution.stores.relational.connection.tests.api.TestConnectionIntegration; import org.finos.legend.engine.plan.execution.stores.relational.connection.tests.api.TestConnectionIntegrationLoader; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseType; @@ -27,7 +28,7 @@ public static RelationalDatabaseConnection getDatabaseConnection(DatabaseType db TestConnectionIntegration found = TestConnectionIntegrationLoader.extensions().select(c -> c.getDatabaseType() == dbType).getFirst(); if (found == null) { - throw new PureExecutionException("Can't find a TestConnectionIntegration for dbType " + dbType + ". Available ones are " + TestConnectionIntegrationLoader.extensions().collect(c -> c.getDatabaseType().name())); + throw new PureExecutionException("Can't find a TestConnectionIntegration for dbType " + dbType + ". Available ones are " + TestConnectionIntegrationLoader.extensions().collect(c -> c.getDatabaseType().name()), Stacks.mutable.empty()); } return found.getConnection(); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/pom.xml index 43a23e1af10..929bb98f525 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-test-deprecated - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-relationalStore-test-http-server diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/src/main/java/org/finos/legend/engine/server/test/shared/Relational_DbSpecific_UsingPureClientTestSuite.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/src/main/java/org/finos/legend/engine/server/test/shared/Relational_DbSpecific_UsingPureClientTestSuite.java index 2c2e182804b..96498b6527e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/src/main/java/org/finos/legend/engine/server/test/shared/Relational_DbSpecific_UsingPureClientTestSuite.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-http-server/src/main/java/org/finos/legend/engine/server/test/shared/Relational_DbSpecific_UsingPureClientTestSuite.java @@ -19,6 +19,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.impl.utility.ArrayIterate; import org.finos.legend.pure.m3.execution.test.PureTestBuilder; import org.finos.legend.pure.runtime.java.compiled.testHelper.PureTestBuilderCompiled; @@ -97,9 +98,9 @@ protected void runTest() throws Throwable System.out.println("| **" + dbTestName + "** | deviates-from-standard :ballot_box_with_check: |"); if (e instanceof PureAssertFailException) { - throw new PureAssertFailException(e.getSourceInformation(), "[unsupported-api] [deviating-from-standard] " + e.getInfo(), (PureAssertFailException) e); + throw new PureAssertFailException(e.getSourceInformation(), "[unsupported-api] [deviating-from-standard] " + e.getInfo(), (PureAssertFailException) e, Stacks.mutable.empty()); } - throw new PureExecutionException(e.getSourceInformation(), "[unsupported-api] [deviating-from-standard] " + e.getInfo(), e); + throw new PureExecutionException(e.getSourceInformation(), "[unsupported-api] [deviating-from-standard] " + e.getInfo(), e, Stacks.mutable.empty()); } if ((e.getInfo() == null ? "" : e.getInfo()).toLowerCase().startsWith("[unsupported-api]")) { diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-mutation/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-mutation/pom.xml index d30083930fb..7d0ec9fd29e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-mutation/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-mutation/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-test-deprecated - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-reports/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-reports/pom.xml index f97d31ac6e9..1a32c635fb6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-reports/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/legend-engine-xt-relationalStore-test-reports/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-test-deprecated - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-relationalStore-test-reports diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/pom.xml index 37d9772e6b1..9844d714a58 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/legend-engine-xt-relationalStore-test-deprecated/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-PCT - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/pom.xml index a8720a1acb9..e65cfef23f9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-PCT/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-relationalStore - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/pom.xml index 89e4f98b1d2..84bea53c874 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/pom.xml @@ -19,7 +19,7 @@ legend-engine-xt-relationalStore-analytics org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -119,5 +119,10 @@ jackson-databind test + + org.hamcrest + hamcrest-core + test + \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/java/org/finos/legend/engine/entitlement/TestRelationalStoreEntitlementAnalytics.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/java/org/finos/legend/engine/entitlement/TestRelationalStoreEntitlementAnalytics.java index 808a7f2456c..516fcdcc649 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/java/org/finos/legend/engine/entitlement/TestRelationalStoreEntitlementAnalytics.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/java/org/finos/legend/engine/entitlement/TestRelationalStoreEntitlementAnalytics.java @@ -27,12 +27,14 @@ import org.finos.legend.engine.shared.core.deployment.DeploymentMode; import org.finos.legend.engine.shared.core.deployment.DeploymentStateAndVersions; import org.finos.legend.engine.shared.core.identity.Identity; -import org.finos.legend.engine.shared.core.identity.factory.*; +import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; import org.finos.legend.pure.generated.Root_meta_core_runtime_Runtime; import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping; import org.finos.legend.pure.m3.coreinstance.meta.pure.store.Store; import org.finos.legend.pure.generated.core_relational_store_entitlement_utility_relationalTableAnalyzer; import org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database; +import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Test; @@ -127,7 +129,7 @@ public void testGenerateDatasetEntitlementReports() } @Test - public void testCircularDatabaseRetrievability() + public void testDependencyDatabaseRetrievability() { String pureModelString = getResourceAsString("models/relationalModel.pure"); PureModelContextData pureModelContextData = PureGrammarParser.newInstance().parseModel(pureModelString, false); @@ -135,4 +137,22 @@ public void testCircularDatabaseRetrievability() Store store = pureModel.getStore("store::CovidDataStoreA"); Assert.assertEquals(core_relational_store_entitlement_utility_relationalTableAnalyzer.Root_meta_analytics_store_entitlements_getTablesFromDatabase_Database_1__Table_MANY_((Database) store, pureModel.getExecutionSupport()).size(), 2); } + + @Test + public void testCircularDependencyInDatabases() + { + String pureModelString = getResourceAsString("models/databaseCircularDependency.pure"); + PureModelContextData pureModelContextData = PureGrammarParser.newInstance().parseModel(pureModelString, false); + String expectedErrorMessage = "COMPILATION error: Detected a circular dependency in element prerequisites graph in the following metamodel: class org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database"; + try + { + Compiler.compile(pureModelContextData, DeploymentMode.TEST, Identity.getAnonymousIdentity().getName()); + Assert.fail("Expected compilation error with message: " + expectedErrorMessage + "; but no error occurred"); + } + catch (EngineException e) + { + MatcherAssert.assertThat(EngineException.buildPrettyErrorMessage(e.getMessage(), e.getSourceInformation(), + e.getErrorType()), CoreMatchers.startsWith(expectedErrorMessage)); + } + } } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/resources/models/databaseCircularDependency.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/resources/models/databaseCircularDependency.pure new file mode 100644 index 00000000000..26fed10c5c6 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/resources/models/databaseCircularDependency.pure @@ -0,0 +1,32 @@ +###Relational +Database store::CovidDataStoreA +( + include store::CovidDataStoreB +) + +Database store::CovidDataStoreB +( + include store::CovidDataStoreC +) + +Database store::CovidDataStoreC +( + include store::CovidDataStoreA + + Table DEMOGRAPHICS + ( + FIPS VARCHAR(200), + STATE VARCHAR(200) + ) + Table COVID_DATA + ( + ID INTEGER PRIMARY KEY, + FIPS VARCHAR(200), + DATE DATE, + CASE_TYPE VARCHAR(200), + CASES INTEGER, + LAST_REPORTED_FLAG BIT + ) + + Join CovidDataDemographicsJoin(DEMOGRAPHICS.FIPS = COVID_DATA.FIPS) +) diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/resources/models/relationalModel.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/resources/models/relationalModel.pure index b19601ee5c2..03d1bdc90b0 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/resources/models/relationalModel.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-analytics/src/test/resources/models/relationalModel.pure @@ -31,7 +31,6 @@ Database store::CovidDataStoreB Database store::CovidDataStoreC ( - include store::CovidDataStoreA Table DEMOGRAPHICS ( FIPS VARCHAR(200), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-pure/pom.xml index 1fe771f9cda..33a117cbd75 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/legend-engine-xt-relationalStore-store-entitlement-pure/pom.xml @@ -19,7 +19,7 @@ legend-engine-xt-relationalStore-analytics org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/pom.xml index 4c77fa902b3..7f49c0dc27a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-analytics/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-relationalStore - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-connection-http-api/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-connection-http-api/pom.xml index ad202fee05e..03b73d33406 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-connection-http-api/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-connection-http-api/pom.xml @@ -19,7 +19,7 @@ legend-engine-xts-relationalStore org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution-tests/pom.xml index 5fae2b5fe47..2272c2a121a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution-tests/pom.xml @@ -3,7 +3,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-athena - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution/pom.xml index eafd489aaad..ad950876194 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-athena - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-grammar/pom.xml index 88fd757b4fb..1ee1aec33d5 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-athena - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-protocol/pom.xml index 191d71a589b..893ccf556ca 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-athena - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-pure/pom.xml index 9fe403c2819..5bdef1c2b18 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/legend-engine-xt-relationalStore-athena-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-athena - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/pom.xml index c4c90cfe3e0..bd353a27697 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-athena/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution-tests/pom.xml index bc1842eff21..691b31a60b1 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution-tests/pom.xml @@ -3,7 +3,7 @@ legend-engine-xt-relationalStore-bigquery org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution/pom.xml index 4c6ccb38460..5cf2fbee5eb 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-bigquery - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-grammar/pom.xml index 45c1cd3e454..28abc4106fb 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-bigquery - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-protocol/pom.xml index 70fce5ff7c5..c14234fc947 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-bigquery - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-pure/pom.xml index 8ecd30df32e..13b3a85cf5e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/legend-engine-xt-relationalStore-bigquery-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-bigquery - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/pom.xml index d3caa33e005..3c87baf8a78 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-bigquery/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution-tests/pom.xml index 94d6c550cff..469805f5a79 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution-tests/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-databricks - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution/pom.xml index 2b246a0e1f2..012ae9b3c3b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-databricks - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-grammar/pom.xml index c4afcae0373..8e5f5f9ba5b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-databricks - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-protocol/pom.xml index f16a937bd1a..fda55d6f252 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-databricks - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-pure/pom.xml index b23770d41e6..b45db97421c 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/legend-engine-xt-relationalStore-databricks-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-databricks - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/pom.xml index 1f9c41afc77..cdecf97ae76 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-databricks/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/pom.xml index 2b48005945c..24ff1221f9b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-duckdb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -211,11 +211,6 @@ legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions test - - org.finos.legend.engine - legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions - test - org.finos.legend.engine legend-engine-xt-relationalStore-core-pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_EssentialFunctions_PCT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_EssentialFunctions_PCT.java index c9d693a92dc..70e57e9ab17 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_EssentialFunctions_PCT.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_EssentialFunctions_PCT.java @@ -53,7 +53,7 @@ public class Test_Relational_DuckDB_EssentialFunctions_PCT extends PCTReportConf // Drop one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::drop::testDropManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::drop::testDropNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the drop function. Expected a value, found operation/function\""), @@ -68,8 +68,8 @@ public class Test_Relational_DuckDB_EssentialFunctions_PCT extends PCTReportConf // Find one("meta::pure::functions::collection::tests::find::testFindInstance_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:38cc38-42); error compiling generated Java code:\nimport org.eclipse.collections.api.LazyIterable;\nimport org.eclipse.collections.api.block.function.Function0;\nimport org.eclipse.collections.api.block.function.Function;\nimport org.eclipse.collections.api.block.function.Function2;\nimport org.eclipse.collections.api.block.predicate.Predicate;\nimport org.eclipse.collections.api.block.procedure.Procedure;\nimport org.eclipse.collections.api.map.ImmutableMap;\nimport org.eclipse.collections.api.map.MutableMap;\nimport org.eclipse.collections.api.map.MutableMapIterable;\nimport org.eclipse.collections.api.map.MapIterable;\nimport org.eclipse.collections.api.map.primitive.IntObjectMap;\nimport org.eclipse.collections.api.set.MutableSet;\nimport org.eclipse.collections.api.set.SetIterable;\nimport org.eclipse.collections.api.list.MutableList;\nimport org.eclipse.collections.api.list.ListIterable;\nimport org.eclipse.collections.api.RichIterable;\nimport org.eclipse.collections.api.tuple.Pair;\nimport org.eclipse.collections.impl.factory.Lists;\nimport org.eclipse.collections.impl.factory.Maps;\nimport org.eclipse.collections.impl.map.mutable.UnifiedMap;\nimport org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy;\nimport org.eclipse.collections.impl.set.mutable.UnifiedSet;\nimport org.eclipse.collections.impl.set.strategy.mutable.UnifiedSetWithHashingStrategy;\nimport org.eclipse.collections.impl.list.mutable.FastList;\nimport org.eclipse.collections.impl.factory.Sets;\nimport org.eclipse.collections.impl.block.function.checked.CheckedFunction0;\nimport org.eclipse.collections.impl.utility.Iterate;\nimport org.eclipse.collections.impl.utility.LazyIterate;\nimport org.eclipse.collections.impl.utility.StringIterate;\nimport org.finos.legend.pure.m3.navigation.generictype.GenericType;\nimport org.finos.legend.pure.m3.navigation.ProcessorSupport;\nimport org.finos.legend.pure.m3.execution.ExecutionSupport;\nimport org.finos.legend.pure.m3.exception.PureExecutionException;\nimport org.finos.legend.pure.m4.coreinstance.CoreInstance;\nimport org.finos.legend.pure.m4.coreinstance.primitive.date.PureDate;\nimport org.finos.legend.pure.m4.coreinstance.primitive.date.DateFunctions;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.coreinstance.*;\nimport org.finos.legend.pure.runtime.java.compiled.metadata.*;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.map.*;\nimport org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.vcs.ChangeType;\nimport org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.vcs.ChangedPath;\nimport org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.vcs.Revision;\nimport org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement;\nimport org.finos.legend.pure.m3.tools.ListHelper;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.*;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.function.defended.*;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.function.*;\nimport org.finos.legend.pure.runtime.java.compiled.execution.*;\nimport org.finos.legend.pure.runtime.java.compiled.execution.sourceInformation.*;\nimport org.finos.legend.pure.runtime.java.compiled.serialization.model.*;\nimport org.finos.legend.pure.runtime.java.compiled.metadata.*;\nimport java.lang.reflect.Method;\nimport java.math.BigInteger;\nimport java.sql.DatabaseMetaData;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSetMetaData;\nimport java.util.Iterator;\nimport java.util.Calendar;\nimport java.util.Map;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport org.json.simple.JSONObject;\nimport org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization;\nimport org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type;\n\n\npublic class DynaClass{\n public static org.finos.legend.pure.generated.Root_meta_pure_functions_collection_tests_model_CO_Person doProcess(final MapIterable vars, final MutableMap valMap, final IntObjectMap localLambdas, final ExecutionSupport es){\n return _smith;\n }\n}\n"), - one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), - one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), one("meta::pure::functions::collection::tests::find::testFindUsingVarForFunction_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:47cc38-42); error compiling generated Java code:\nimport org.eclipse.collections.api.LazyIterable;\nimport org.eclipse.collections.api.block.function.Function0;\nimport org.eclipse.collections.api.block.function.Function;\nimport org.eclipse.collections.api.block.function.Function2;\nimport org.eclipse.collections.api.block.predicate.Predicate;\nimport org.eclipse.collections.api.block.procedure.Procedure;\nimport org.eclipse.collections.api.map.ImmutableMap;\nimport org.eclipse.collections.api.map.MutableMap;\nimport org.eclipse.collections.api.map.MutableMapIterable;\nimport org.eclipse.collections.api.map.MapIterable;\nimport org.eclipse.collections.api.map.primitive.IntObjectMap;\nimport org.eclipse.collections.api.set.MutableSet;\nimport org.eclipse.collections.api.set.SetIterable;\nimport org.eclipse.collections.api.list.MutableList;\nimport org.eclipse.collections.api.list.ListIterable;\nimport org.eclipse.collections.api.RichIterable;\nimport org.eclipse.collections.api.tuple.Pair;\nimport org.eclipse.collections.impl.factory.Lists;\nimport org.eclipse.collections.impl.factory.Maps;\nimport org.eclipse.collections.impl.map.mutable.UnifiedMap;\nimport org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy;\nimport org.eclipse.collections.impl.set.mutable.UnifiedSet;\nimport org.eclipse.collections.impl.set.strategy.mutable.UnifiedSetWithHashingStrategy;\nimport org.eclipse.collections.impl.list.mutable.FastList;\nimport org.eclipse.collections.impl.factory.Sets;\nimport org.eclipse.collections.impl.block.function.checked.CheckedFunction0;\nimport org.eclipse.collections.impl.utility.Iterate;\nimport org.eclipse.collections.impl.utility.LazyIterate;\nimport org.eclipse.collections.impl.utility.StringIterate;\nimport org.finos.legend.pure.m3.navigation.generictype.GenericType;\nimport org.finos.legend.pure.m3.navigation.ProcessorSupport;\nimport org.finos.legend.pure.m3.execution.ExecutionSupport;\nimport org.finos.legend.pure.m3.exception.PureExecutionException;\nimport org.finos.legend.pure.m4.coreinstance.CoreInstance;\nimport org.finos.legend.pure.m4.coreinstance.primitive.date.PureDate;\nimport org.finos.legend.pure.m4.coreinstance.primitive.date.DateFunctions;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.coreinstance.*;\nimport org.finos.legend.pure.runtime.java.compiled.metadata.*;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.map.*;\nimport org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.vcs.ChangeType;\nimport org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.vcs.ChangedPath;\nimport org.finos.legend.pure.m3.serialization.filesystem.usercodestorage.vcs.Revision;\nimport org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement;\nimport org.finos.legend.pure.m3.tools.ListHelper;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.*;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.function.defended.*;\nimport org.finos.legend.pure.runtime.java.compiled.generation.processors.support.function.*;\nimport org.finos.legend.pure.runtime.java.compiled.execution.*;\nimport org.finos.legend.pure.runtime.java.compiled.execution.sourceInformation.*;\nimport org.finos.legend.pure.runtime.java.compiled.serialization.model.*;\nimport org.finos.legend.pure.runtime.java.compiled.metadata.*;\nimport java.lang.reflect.Method;\nimport java.math.BigInteger;\nimport java.sql.DatabaseMetaData;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSetMetaData;\nimport java.util.Iterator;\nimport java.util.Calendar;\nimport java.util.Map;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport org.json.simple.JSONObject;\nimport org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization;\nimport org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type;\n\n\npublic class DynaClass{\n public static org.finos.legend.pure.generated.Root_meta_pure_functions_collection_tests_model_CO_Person doProcess(final MapIterable vars, final MutableMap valMap, final IntObjectMap localLambdas, final ExecutionSupport es){\n return _smith;\n }\n}\n"), // Fold @@ -95,9 +95,9 @@ public class Test_Relational_DuckDB_EssentialFunctions_PCT extends PCTReportConf one("meta::pure::functions::collection::tests::indexof::testIndexOf_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'indexOf_T_MANY__T_1__Integer_1_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), // Init - one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), // Last one("meta::pure::functions::collection::tests::last::testLastFromEmpty_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'last_T_MANY__T_$0_1$_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), @@ -116,7 +116,7 @@ public class Test_Relational_DuckDB_EssentialFunctions_PCT extends PCTReportConf // Slice one("meta::pure::functions::collection::tests::slice::testSliceEqualBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::slice::testSliceOnBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::slice::testSliceOnEmpty_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::slice::testSliceOutOfBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), @@ -139,7 +139,7 @@ public class Test_Relational_DuckDB_EssentialFunctions_PCT extends PCTReportConf // Take one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::take::testTakeManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::take::testTakeNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the take/limit function. Expected a value, found operation/function\""), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_GrammarFunctions_PCT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_GrammarFunctions_PCT.java index a926035c765..be0be00dff2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_GrammarFunctions_PCT.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/duckdb/pct/Test_Relational_DuckDB_GrammarFunctions_PCT.java @@ -45,12 +45,14 @@ public class Test_Relational_DuckDB_GrammarFunctions_PCT extends PCTReportConfig one("meta::pure::functions::boolean::tests::equality::eq::testEqNonPrimitive_Function_1__Boolean_1_", "Error while executing: insert into leSchema.SideClass (_pureId,stringId,intId) values (10,'firstSide',1);"), one("meta::pure::functions::boolean::tests::equality::eq::testEqVarIdentity_Function_1__Boolean_1_", "\"The system is trying to get an element at offset 1 where the collection is of size 1\""), one("meta::pure::functions::boolean::tests::equality::eq::testEqEnum_Function_1__Boolean_1_", "\"Assert failed\""), + one("meta::pure::functions::boolean::tests::equality::eq::testEqPrimitiveExtension_Function_1__Boolean_1_", "Can't find a match for function 'meta::pure::functions::boolean::eq(SideClass[*],Nil[1])'"), // Equal one("meta::pure::functions::boolean::tests::equality::equal::testEqualEnum_Function_1__Boolean_1_", "\"Assert failed\""), one("meta::pure::functions::boolean::tests::equality::equal::testEqualNonPrimitive_Function_1__Boolean_1_", "Error while executing: insert into leSchema.SideClass (_pureId,stringId,intId) values (10,'firstSide',1);"), one("meta::pure::functions::boolean::tests::equality::equal::testEqualVarIdentity_Function_1__Boolean_1_", "\"The system is trying to get an element at offset 1 where the collection is of size 1\""), one("meta::pure::functions::boolean::tests::equality::equal::testEqualDateStrictYear_Function_1__Boolean_1_", "\"DuckDB doesn't support YEAR and YEAR-MONTH\""), + one("meta::pure::functions::boolean::tests::equality::equal::testEqualPrimitiveExtension_Function_1__Boolean_1_", "\"Filter expressions are only supported for Primitives and Enums. Filter contains a parameter of type SideClass\""), // GreaterThan one("meta::pure::functions::boolean::tests::inequalities::greaterThan::testGreaterThan_Boolean_Function_1__Boolean_1_", "\"Assert failed\""), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-execution/pom.xml index 3de6c73c98d..3298e1db90e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-duckdb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/pom.xml index c3a020c0803..ac22b756311 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-duckdb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-protocol/pom.xml index e5e52dcf1bd..b3acb5b382b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-duckdb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-pure/pom.xml index b07e785b312..276fc4e2665 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-duckdb - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/pom.xml new file mode 100644 index 00000000000..094ab3152e5 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/pom.xml @@ -0,0 +1,181 @@ + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-duckdb + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure + jar + Legend Engine - XT - Relational Store - DuckDB - SQL Dialect Translation - Pure + + + + + org.finos.legend.pure + legend-pure-maven-generation-par + + ${project.basedir}/src/main/resources + ${legend.pure.version} + + core_external_store_relational_sql_dialect_translation_duckdb + + + ${project.basedir}/src/main/resources/core_external_store_relational_sql_dialect_translation_duckdb.definition.json + + + + + generate-sources + + build-pure-jar + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-sqlDialectTranslation-pure + ${project.version} + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + + + org.finos.legend.pure + legend-pure-maven-generation-java + + + compile + + build-pure-compiled-jar + + + true + true + modular + true + + core_external_store_relational_sql_dialect_translation_duckdb + + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-sqlDialectTranslation-pure + ${project.version} + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + + + + maven-surefire-plugin + + false + + **/Test_DuckDB_SDT*.java + **/SdtTestSuiteBuilder*.java + + + + + + + + + + org.finos.legend.pure + legend-pure-m4 + + + org.finos.legend.pure + legend-pure-m3-core + + + org.finos.legend.pure + legend-pure-runtime-java-engine-compiled + + + + + + org.finos.legend.engine + legend-engine-pure-platform-java + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + + + org.finos.legend.engine + legend-engine-xt-relationalStore-sqlDialectTranslation-pure + + + + + org.eclipse.collections + eclipse-collections + + + org.eclipse.collections + eclipse-collections-api + + + + + junit + junit + + + org.finos.legend.engine + legend-engine-xt-relationalStore-SDT-pure + test + + + org.finos.legend.engine + legend-engine-xt-relationalStore-duckdb-PCT + test + + + org.finos.legend.engine + legend-engine-xt-relationalStore-SDT-pure + test-jar + ${project.version} + test + + + + diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQueryConfigurationDeserializer.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/java/org/finos/legend/pure/code/core/CoreExternalStoreRelationalSqlDialectTranslationDuckDBCodeRepositoryProvider.java similarity index 51% rename from legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQueryConfigurationDeserializer.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/java/org/finos/legend/pure/code/core/CoreExternalStoreRelationalSqlDialectTranslationDuckDBCodeRepositoryProvider.java index 2bcbe962a39..1897b4045cf 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/server/model/DataCubeQueryConfigurationDeserializer.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/java/org/finos/legend/pure/code/core/CoreExternalStoreRelationalSqlDialectTranslationDuckDBCodeRepositoryProvider.java @@ -12,21 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -package org.finos.legend.engine.repl.dataCube.server.model; +package org.finos.legend.pure.code.core; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.TreeNode; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepository; +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider; +import org.finos.legend.pure.m3.serialization.filesystem.repository.GenericCodeRepository; -import java.io.IOException; - -public class DataCubeQueryConfigurationDeserializer extends JsonDeserializer +public class CoreExternalStoreRelationalSqlDialectTranslationDuckDBCodeRepositoryProvider implements CodeRepositoryProvider { @Override - public String deserialize(JsonParser jp, DeserializationContext ctx) throws IOException + public CodeRepository repository() { - TreeNode tree = jp.getCodec().readTree(jp); - return tree.toString(); + return GenericCodeRepository.build("core_external_store_relational_sql_dialect_translation_duckdb.definition.json"); } -} \ No newline at end of file +} + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider new file mode 100644 index 00000000000..03f3448f973 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider @@ -0,0 +1 @@ +org.finos.legend.pure.code.core.CoreExternalStoreRelationalSqlDialectTranslationDuckDBCodeRepositoryProvider \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation_duckdb.definition.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation_duckdb.definition.json new file mode 100644 index 00000000000..3fc3c5aee00 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation_duckdb.definition.json @@ -0,0 +1,19 @@ +{ + "name": "core_external_store_relational_sql_dialect_translation_duckdb", + "pattern": "(meta::external::store::relational::sqlDialectTranslation::duckDB)(::.*)?", + "dependencies": [ + "platform", + "platform_dsl_store", + "platform_dsl_mapping", + "platform_dsl_path", + "platform_dsl_graph", + "platform_dsl_diagram", + "platform_store_relational", + "core_functions_standard", + "core_functions_unclassified", + "core_functions_json", + "core", + "core_external_store_relational_postgres_sql_model", + "core_external_store_relational_sql_dialect_translation" + ] +} \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation_duckdb/duckDBSqlDialect.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation_duckdb/duckDBSqlDialect.pure new file mode 100644 index 00000000000..1603ac173b1 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation_duckdb/duckDBSqlDialect.pure @@ -0,0 +1,162 @@ +// Copyright 2024 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 meta::external::query::sql::metamodel::*; +import meta::external::store::relational::sqlDialectTranslation::*; +import meta::external::store::relational::sqlDialectTranslation::defaults::*; +import meta::external::store::relational::sqlDialectTranslation::duckDB::*; +import meta::external::store::relational::sqlDialectTranslation::utils::*; +import meta::pure::extension::*; + +function meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBSqlDialect(): SqlDialect[1] +{ + ^SqlDialect + ( + dbType = 'DuckDB', + quoteConfig = duckDBQuoteConfiguration(), + nodeProcessors = duckDBDialectNodeProcessors(), + identifierProcessor = duckDBIdentifierProcessor(), + expressionPrecedenceComparator = duckDBExpressionPrecedenceComparator(), + keywords = duckDBKeywords() + ) +} + + +function meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBSqlDialectExtension(): Extension[1] +{ + ^Extension + ( + type = 'DuckDBSqlDialectExtension', + moduleExtensions = [ + ^SqlDialectTranslationModuleExtension + ( + module = sqlDialectTranslationModuleExtensionName(), + extraSqlDialects = duckDBSqlDialect() + ) + ] + ) +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBQuoteConfiguration(): QuoteConfiguration[1] +{ + ^QuoteConfiguration + ( + start = '"', + end = '"', + escape = '""' + ) +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBDialectNodeProcessors(): Map, NodeProcessor>[1] +{ + newMap( + duckDBDialectStatementProcessors() + ->concatenate( + duckDBDialectRelationProcessors() + ) + ->concatenate( + duckDBDialectExpressionProcessors() + ) + ->concatenate( + duckDBDialectLiteralProcessors() + ) + ->concatenate( + duckDBDialectSelectItemProcessors() + ) + ->concatenate( + duckDBDialectOtherNodeProcessors() + ) + ->map(n | pair($n.nodeType, $n)) + ) +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBDialectStatementProcessors(): NodeProcessor[*] +{ + [ + queryProcessor_default(), + windowProcessor_default() + ] +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBDialectRelationProcessors(): NodeProcessor[*] +{ + [ + tableProcessor_default(), + aliasedRelationProcessor_default(), + joinProcessor_default(), + querySpecificationProcessor_default(), + unionProcessor_default() + ] +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBDialectExpressionProcessors(): NodeProcessor[*] +{ + [ + comparisonExpressionNodeProcessor_default(), + logicalBinaryExpressionNodeProcessor_default(), + notExpressionNodeProcessor_default(), + arithmeticExpressionNodeProcessor_default(), + columnTypeProcessor_default(), + castProcessor_default() + ] +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBDialectLiteralProcessors(): NodeProcessor[*] +{ + [ + integerLiteralNodeProcessor_default(), + stringLiteralNodeProcessor_default(), + booleanLiteralNodeProcessor_default(), + longLiteralNodeProcessor_default(), + doubleLiteralNodeProcessor_default(), + nullLiteralNodeProcessor_default() + ] +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBDialectSelectItemProcessors(): NodeProcessor[*] +{ + [ + allColumnsNodeProcessor_default(), + singleColumnNodeProcessor_default() + ] +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBDialectOtherNodeProcessors(): NodeProcessor[*] +{ + [ + sortItemProcessor_default(), + selectProcessor_default() + ] +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBIdentifierProcessor(): IdentifierProcessor[1] +{ + identifierProcessor_default() +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBExpressionPrecedenceComparator(): ExpressionPrecedenceComparator[1] +{ + ^ExpressionPrecedenceComparator( + findOperatorType = findOperatorType_default_Expression_1__String_1_, + operatorPrecedence = operatorPrecedence_default() + ) +} + +function <> meta::external::store::relational::sqlDialectTranslation::duckDB::duckDBKeywords(): String[*] +{ + [ + // TODO: Update + 'date' + ] +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/test/java/org/finos/legend/engine/relational/sdt/duckdb/Test_DuckDB_SDT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/test/java/org/finos/legend/engine/relational/sdt/duckdb/Test_DuckDB_SDT.java new file mode 100644 index 00000000000..d6e840bbcb5 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/test/java/org/finos/legend/engine/relational/sdt/duckdb/Test_DuckDB_SDT.java @@ -0,0 +1,35 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.relational.sdt.duckdb; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Maps; +import org.finos.legend.engine.relational.test.sdt.SdtTestSuiteBuilder; + +import static org.finos.legend.pure.generated.core_external_store_relational_sql_dialect_translation_duckdb_duckDBSqlDialect.Root_meta_external_store_relational_sqlDialectTranslation_duckDB_duckDBSqlDialectExtension__Extension_1_; + +public class Test_DuckDB_SDT extends TestSuite +{ + public static Test suite() + { + return SdtTestSuiteBuilder.buildSdtTestSuite( + "DuckDB", + es -> Lists.immutable.of(Root_meta_external_store_relational_sqlDialectTranslation_duckDB_duckDBSqlDialectExtension__Extension_1_(es)), + Maps.mutable.empty() + ); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/test/java/org/finos/legend/pure/code/core/Test_Pure_ExternalStoreRelationalSqlDialectTranslationDuckDB.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/test/java/org/finos/legend/pure/code/core/Test_Pure_ExternalStoreRelationalSqlDialectTranslationDuckDB.java new file mode 100644 index 00000000000..63b90f9b6dd --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure/src/test/java/org/finos/legend/pure/code/core/Test_Pure_ExternalStoreRelationalSqlDialectTranslationDuckDB.java @@ -0,0 +1,32 @@ +// Copyright 2024 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. + +package org.finos.legend.pure.code.core; + +import junit.framework.TestSuite; +import org.finos.legend.pure.m3.execution.test.PureTestBuilder; +import org.finos.legend.pure.m3.execution.test.TestCollection; +import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport; +import org.finos.legend.pure.runtime.java.compiled.testHelper.PureTestBuilderCompiled; + +public class Test_Pure_ExternalStoreRelationalSqlDialectTranslationDuckDB +{ + public static TestSuite suite() + { + CompiledExecutionSupport executionSupport = PureTestBuilderCompiled.getClassLoaderExecutionSupport(); + TestSuite suite = new TestSuite(); + suite.addTest(PureTestBuilderCompiled.buildSuite(TestCollection.collectTests("meta::external::store::relational::sqlDialectTranslation::duckDB", executionSupport.getProcessorSupport(), fn -> PureTestBuilderCompiled.generatePureTestCollection(fn, executionSupport), ci -> PureTestBuilder.satisfiesConditions(ci, executionSupport.getProcessorSupport())), executionSupport)); + return suite; + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/pom.xml index b3996ed725a..cb06b8c4acf 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/pom.xml @@ -3,7 +3,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -18,6 +18,7 @@ legend-engine-xt-relationalStore-duckdb-grammar legend-engine-xt-relationalStore-duckdb-protocol legend-engine-xt-relationalStore-duckdb-pure + legend-engine-xt-relationalStore-duckdb-sqlDialectTranslation-pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/pom.xml index 97f0970b05a..14556838e00 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-h2 - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_EssentialFunctions_PCT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_EssentialFunctions_PCT.java index 854cb2d289c..dde93a5d2fd 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_EssentialFunctions_PCT.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_EssentialFunctions_PCT.java @@ -53,7 +53,7 @@ public class Test_Relational_H2_EssentialFunctions_PCT extends PCTReportConfigur // Drop one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::drop::testDropManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::drop::testDropNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the drop function. Expected a value, found operation/function\""), @@ -68,8 +68,8 @@ public class Test_Relational_H2_EssentialFunctions_PCT extends PCTReportConfigur // Find one("meta::pure::functions::collection::tests::find::testFindInstance_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:38cc38-42); error compiling generated Java code:"), - one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), - one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), one("meta::pure::functions::collection::tests::find::testFindUsingVarForFunction_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:47cc38-42); error compiling generated Java code:"), // Fold @@ -95,9 +95,9 @@ public class Test_Relational_H2_EssentialFunctions_PCT extends PCTReportConfigur one("meta::pure::functions::collection::tests::indexof::testIndexOf_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'indexOf_T_MANY__T_1__Integer_1_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), // Init - one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), // Last one("meta::pure::functions::collection::tests::last::testLastFromEmpty_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'last_T_MANY__T_$0_1$_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), @@ -113,7 +113,7 @@ public class Test_Relational_H2_EssentialFunctions_PCT extends PCTReportConfigur // Slice one("meta::pure::functions::collection::tests::slice::testSliceEqualBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::slice::testSliceOnBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::slice::testSliceOnEmpty_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::slice::testSliceOutOfBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), @@ -136,7 +136,7 @@ public class Test_Relational_H2_EssentialFunctions_PCT extends PCTReportConfigur // Take one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::take::testTakeManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::take::testTakeNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the take/limit function. Expected a value, found operation/function\""), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_GrammarFunctions_PCT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_GrammarFunctions_PCT.java index d5736e62954..a8cadb45fa1 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_GrammarFunctions_PCT.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/legend-engine-xt-relationalStore-h2-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/h2/pct/Test_Relational_H2_GrammarFunctions_PCT.java @@ -50,12 +50,14 @@ public class Test_Relational_H2_GrammarFunctions_PCT extends PCTReportConfigurat one("meta::pure::functions::boolean::tests::equality::eq::testEqEnum_Function_1__Boolean_1_", "\"Assert failed\""), one("meta::pure::functions::boolean::tests::equality::eq::testEqNonPrimitive_Function_1__Boolean_1_", "Error while executing: insert into leSchema.SideClass (_pureId,stringId,intId) values (10,'firstSide',1);"), one("meta::pure::functions::boolean::tests::equality::eq::testEqVarIdentity_Function_1__Boolean_1_", "\"The system is trying to get an element at offset 1 where the collection is of size 1\""), + one("meta::pure::functions::boolean::tests::equality::eq::testEqPrimitiveExtension_Function_1__Boolean_1_", "Can't find a match for function 'meta::pure::functions::boolean::eq(SideClass[*],Nil[1])'"), // Equal one("meta::pure::functions::boolean::tests::equality::equal::testEqualDateStrictYear_Function_1__Boolean_1_", "\"Ensure the target system understands Year or Year-month semantic.\""), one("meta::pure::functions::boolean::tests::equality::equal::testEqualEnum_Function_1__Boolean_1_", "\"Assert failed\""), one("meta::pure::functions::boolean::tests::equality::equal::testEqualNonPrimitive_Function_1__Boolean_1_", "Error while executing: insert into leSchema.SideClass (_pureId,stringId,intId) values (10,'firstSide',1);"), one("meta::pure::functions::boolean::tests::equality::equal::testEqualVarIdentity_Function_1__Boolean_1_", "\"The system is trying to get an element at offset 1 where the collection is of size 1\""), + one("meta::pure::functions::boolean::tests::equality::equal::testEqualPrimitiveExtension_Function_1__Boolean_1_", "\"Filter expressions are only supported for Primitives and Enums. Filter contains a parameter of type SideClass\""), // GreaterThan one("meta::pure::functions::boolean::tests::inequalities::greaterThan::testGreaterThan_Boolean_Function_1__Boolean_1_", "\"Assert failed\""), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/pom.xml index 64f5ad5958c..1d72e9c9fdc 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-h2/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/legend-engine-xt-relationalStore-hive-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/legend-engine-xt-relationalStore-hive-pure/pom.xml index 6c5c9ccb278..0c992da9469 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/legend-engine-xt-relationalStore-hive-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/legend-engine-xt-relationalStore-hive-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-hive - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/pom.xml index 60c25e81ad7..b55d41ca656 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-hive/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-connection/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-connection/pom.xml index 7622de05262..c2f9d5f5da2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-connection/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-connection/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-memsql - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution-tests/pom.xml index 89722b10d01..7622f107151 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution-tests/pom.xml @@ -19,7 +19,7 @@ legend-engine-xt-relationalStore-memsql org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution/pom.xml index 9792a76e797..ba94088fd87 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-execution/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-memsql - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-relationalStore-memsql-execution @@ -78,7 +78,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-memsql-protocol - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT compile diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-grammar/pom.xml index 9c9e800e2cf..b50e6be86f2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-memsql - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -105,7 +105,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-memsql-protocol - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT org.finos.legend.engine diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-protocol/pom.xml index 90ac779bbb8..b479777eb36 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-protocol/pom.xml @@ -19,7 +19,7 @@ legend-engine-xt-relationalStore-memsql org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-pure/pom.xml index edd396d7d0a..165c3ca7b17 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/legend-engine-xt-relationalStore-memsql-pure/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-memsql - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT legend-engine-xt-relationalStore-memsql-pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/pom.xml index c0592ed7503..049618eecd1 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-memsql/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/pom.xml index 61f37763bbf..31d361c3d23 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-postgres - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -224,11 +224,6 @@ legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions test - - org.finos.legend.engine - legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions - test - org.finos.legend.engine legend-engine-xt-relationalStore-core-pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_EssentialFunctions_PCT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_EssentialFunctions_PCT.java index 26dbdf7ac02..a39f132f7a4 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_EssentialFunctions_PCT.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_EssentialFunctions_PCT.java @@ -53,7 +53,7 @@ public class Test_Relational_Postgres_EssentialFunctions_PCT extends PCTReportCo // Drop one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::drop::testDropManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::drop::testDropNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the drop function. Expected a value, found operation/function\""), @@ -68,8 +68,8 @@ public class Test_Relational_Postgres_EssentialFunctions_PCT extends PCTReportCo // Find one("meta::pure::functions::collection::tests::find::testFindInstance_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:38cc38-42); error compiling generated Java code:"), - one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), - one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), one("meta::pure::functions::collection::tests::find::testFindUsingVarForFunction_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:47cc38-42); error compiling generated Java code:"), // Fold @@ -95,9 +95,9 @@ public class Test_Relational_Postgres_EssentialFunctions_PCT extends PCTReportCo one("meta::pure::functions::collection::tests::indexof::testIndexOf_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'indexOf_T_MANY__T_1__Integer_1_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), // Init - one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), // Last one("meta::pure::functions::collection::tests::last::testLastFromEmpty_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'last_T_MANY__T_$0_1$_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), @@ -113,7 +113,7 @@ public class Test_Relational_Postgres_EssentialFunctions_PCT extends PCTReportCo // Slice one("meta::pure::functions::collection::tests::slice::testSliceEqualBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::slice::testSliceOnBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::slice::testSliceOnEmpty_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::slice::testSliceOutOfBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), @@ -137,7 +137,7 @@ public class Test_Relational_Postgres_EssentialFunctions_PCT extends PCTReportCo // Take one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::take::testTakeManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::take::testTakeNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the take/limit function. Expected a value, found operation/function\""), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_GrammarFunctions_PCT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_GrammarFunctions_PCT.java index afd13dbd5d2..8ad3ade7d6b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_GrammarFunctions_PCT.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/postgres/pct/Test_Relational_Postgres_GrammarFunctions_PCT.java @@ -44,12 +44,14 @@ public class Test_Relational_Postgres_GrammarFunctions_PCT extends PCTReportConf one("meta::pure::functions::boolean::tests::equality::eq::testEqEnum_Function_1__Boolean_1_", "\"Assert failed\""), one("meta::pure::functions::boolean::tests::equality::eq::testEqNonPrimitive_Function_1__Boolean_1_", "Error while executing: insert into leSchema.SideClass (_pureId,stringId,intId) values (10,'firstSide',1);"), one("meta::pure::functions::boolean::tests::equality::eq::testEqVarIdentity_Function_1__Boolean_1_", "\"The system is trying to get an element at offset 1 where the collection is of size 1\""), + one("meta::pure::functions::boolean::tests::equality::eq::testEqPrimitiveExtension_Function_1__Boolean_1_", "Can't find a match for function 'meta::pure::functions::boolean::eq(SideClass[*],Nil[1])'"), // Equal one("meta::pure::functions::boolean::tests::equality::equal::testEqualEnum_Function_1__Boolean_1_", "\"Assert failed\""), one("meta::pure::functions::boolean::tests::equality::equal::testEqualNonPrimitive_Function_1__Boolean_1_", "Error while executing: insert into leSchema.SideClass (_pureId,stringId,intId) values (10,'firstSide',1);"), one("meta::pure::functions::boolean::tests::equality::equal::testEqualVarIdentity_Function_1__Boolean_1_", "\"The system is trying to get an element at offset 1 where the collection is of size 1\""), one("meta::pure::functions::boolean::tests::equality::equal::testEqualDateStrictYear_Function_1__Boolean_1_", "\"Ensure the target system understands Year or Year-month semantic.\""), + one("meta::pure::functions::boolean::tests::equality::equal::testEqualPrimitiveExtension_Function_1__Boolean_1_", "\"Filter expressions are only supported for Primitives and Enums. Filter contains a parameter of type SideClass\""), // GreaterThan one("meta::pure::functions::boolean::tests::inequalities::greaterThan::testGreaterThan_Boolean_Function_1__Boolean_1_", "\"Assert failed\""), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-connection/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-connection/pom.xml index 22302a0ee37..ad159d09485 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-connection/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-connection/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-postgres - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-execution/pom.xml index 2c0ec64d594..26fac2f244b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-postgres - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-pure/pom.xml index 95f22a864ad..3b8e0131cb3 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/legend-engine-xt-relationalStore-postgres-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-postgres - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/pom.xml index f693173d30e..acf9966d024 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-postgres/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/legend-engine-xt-relationalStore-presto-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/legend-engine-xt-relationalStore-presto-pure/pom.xml index 7119f50dcc4..3be613b1428 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/legend-engine-xt-relationalStore-presto-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/legend-engine-xt-relationalStore-presto-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-presto - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/pom.xml index bf21187097e..2df340b905a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-presto/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution-tests/pom.xml index 57596b5a2fa..f4deddfbffc 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution-tests/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-redshift - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution/pom.xml index 7b5e1cdce5e..7741c5d381c 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-redshift - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-grammar/pom.xml index c57eaccbd28..bec1e3ddec3 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-redshift - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-protocol/pom.xml index ad3d5df57a1..0d312ef3889 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-redshift - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-pure/pom.xml index e965bc48070..ea177822d36 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/legend-engine-xt-relationalStore-redshift-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-redshift - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/pom.xml index 4b3af73bd85..efeebdf3512 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-redshift/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/pom.xml index d64bb0dc796..9bf3e2ec7f6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-snowflake - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -204,7 +204,6 @@ org.finos.legend.pure legend-pure-m3-core - test org.finos.legend.pure @@ -251,11 +250,6 @@ legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions test - - org.finos.legend.engine - legend-engine-pure-runtime-java-extension-compiled-functions-pureExtensions - test - org.finos.legend.engine legend-engine-xt-relationalStore-core-pure @@ -266,10 +260,6 @@ legend-engine-xt-relationalStore-executionPlan test - - org.finos.legend.pure - legend-pure-m3-core - diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/snowflake/pct/Test_Relational_Snowflake_EssentialFunctions_PCT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/snowflake/pct/Test_Relational_Snowflake_EssentialFunctions_PCT.java index 96ab347f423..a603a9a06d0 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/snowflake/pct/Test_Relational_Snowflake_EssentialFunctions_PCT.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-PCT/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/snowflake/pct/Test_Relational_Snowflake_EssentialFunctions_PCT.java @@ -53,7 +53,7 @@ public class Test_Relational_Snowflake_EssentialFunctions_PCT extends PCTReportC // Drop one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::drop::testDropInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::drop::testDropManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::drop::testDropManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::drop::testDropNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the drop function. Expected a value, found operation/function\""), @@ -68,20 +68,20 @@ public class Test_Relational_Snowflake_EssentialFunctions_PCT extends PCTReportC // Find one("meta::pure::functions::collection::tests::find::testFindInstance_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:38cc38-42); error compiling generated Java code:"), - one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), - one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteralFromVar_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), + one("meta::pure::functions::collection::tests::find::testFindLiteral_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::find' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::find]"), one("meta::pure::functions::collection::tests::find::testFindUsingVarForFunction_Function_1__Boolean_1_", "Error dynamically evaluating value specification (from /platform/pure/essential/collection/iteration/find.pure:47cc38-42); error compiling generated Java code:"), // Fold one("meta::pure::functions::collection::tests::fold::testFoldCollectionAccumulator_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'fold_T_MANY__Function_1__V_m__V_m_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), one("meta::pure::functions::collection::tests::fold::testFoldEmptyListAndEmptyIdentity_Function_1__Boolean_1_", "Can't find a match for function 'meta::pure::functions::collection::add(?)'"), one("meta::pure::functions::collection::tests::fold::testFoldEmptyListAndNonEmptyIdentity_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'fold_T_MANY__Function_1__V_m__V_m_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), - one("meta::pure::functions::collection::tests::fold::testFoldFiltering_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::lang::copy' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::fold, new lambda, Applying meta::pure::functions::lang::if, new lambda, Applying meta::pure::functions::lang::copy]"), + one("meta::pure::functions::collection::tests::fold::testFoldFiltering_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::lang::copy' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::fold, new lambda, Applying meta::pure::functions::lang::if, new lambda, Applying meta::pure::functions::lang::copy]"), one("meta::pure::functions::collection::tests::fold::testFoldMixedAccumulatorTypes_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'fold_T_MANY__Function_1__V_m__V_m_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), - one("meta::pure::functions::collection::tests::fold::testFoldToMany_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::lang::copy' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::fold, new lambda, Applying meta::pure::functions::lang::copy]"), + one("meta::pure::functions::collection::tests::fold::testFoldToMany_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::lang::copy' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::fold, new lambda, Applying meta::pure::functions::lang::copy]"), one("meta::pure::functions::collection::tests::fold::testFoldWithEmptyAccumulator_Function_1__Boolean_1_", "Can't find a match for function 'meta::pure::functions::collection::add(?)'"), one("meta::pure::functions::collection::tests::fold::testFoldWithSingleValue_Function_1__Boolean_1_", "Can't find a match for function 'meta::pure::functions::collection::add(?)'"), - one("meta::pure::functions::collection::tests::fold::testFold_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::lang::copy' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::fold, new lambda, Applying meta::pure::functions::lang::copy]"), + one("meta::pure::functions::collection::tests::fold::testFold_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::lang::copy' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::fold, new lambda, Applying meta::pure::functions::lang::copy]"), one("meta::pure::functions::collection::tests::fold::testIntegerSum_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'fold_T_MANY__Function_1__V_m__V_m_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), one("meta::pure::functions::collection::tests::fold::testStringSum_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'fold_T_MANY__Function_1__V_m__V_m_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), @@ -95,9 +95,9 @@ public class Test_Relational_Snowflake_EssentialFunctions_PCT extends PCTReportC one("meta::pure::functions::collection::tests::indexof::testIndexOf_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'indexOf_T_MANY__T_1__Integer_1_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), // Init - one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), - one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOnEmptySet_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInitOneElement_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), + one("meta::pure::functions::collection::tests::init::testInit_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::init' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::init]"), // Last one("meta::pure::functions::collection::tests::last::testLastFromEmpty_Function_1__Boolean_1_", "\"No SQL translation exists for the PURE function 'last_T_MANY__T_$0_1$_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""), @@ -124,7 +124,7 @@ public class Test_Relational_Snowflake_EssentialFunctions_PCT extends PCTReportC // Slice one("meta::pure::functions::collection::tests::slice::testSliceEqualBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::slice::testSliceInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::slice::testSliceOnBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::slice::testSliceOnEmpty_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::slice::testSliceOutOfBounds_Function_1__Boolean_1_", "\"Cannot cast a collection of size 4 to multiplicity [1]\""), @@ -133,7 +133,7 @@ public class Test_Relational_Snowflake_EssentialFunctions_PCT extends PCTReportC // Take one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeExceedsSizeOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), - one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Fifth Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), + one("meta::pure::functions::collection::tests::take::testTakeInList_Function_1__Boolean_1_", "Can't resolve the builder for function 'meta::pure::functions::collection::list' - stack:[Function 'test::lambdaContainer__Any_MANY_' Third Pass, new lambda, Applying meta::pure::mapping::from, Applying meta::pure::functions::collection::list]"), one("meta::pure::functions::collection::tests::take::testTakeManyOnEmptyList_Function_1__Boolean_1_", "\"Cast exception: SelectSQLQuery cannot be cast to TdsSelectSqlQuery\""), one("meta::pure::functions::collection::tests::take::testTakeManyOnNonEmptyList_Function_1__Boolean_1_", "\"Cannot cast a collection of size 3 to multiplicity [1]\""), one("meta::pure::functions::collection::tests::take::testTakeNegativeOnEmptyList_Function_1__Boolean_1_", "\"Invalid type for parameter inside the take/limit function. Expected a value, found operation/function\""), diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-connection/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-connection/pom.xml index 5889479ec0c..beee2688569 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-connection/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-connection/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-snowflake - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/pom.xml index a37cf0afa43..1dd307648d9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-snowflake - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-grammar/pom.xml index aae7d670aaf..5d011025f33 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-snowflake - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-protocol/pom.xml index 965abeb6342..cdb4b30e3c9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-snowflake - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/pom.xml index 67ee2be6279..033f83b91d0 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-snowflake - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/pom.xml index c61fad84140..0adb3532623 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution-tests/pom.xml index d0a5df0377f..e193bae2bd9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution-tests/pom.xml @@ -3,7 +3,7 @@ legend-engine-xt-relationalStore-spanner org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution/pom.xml index fa6d3a2a549..5ab902144cd 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-execution/pom.xml @@ -19,7 +19,7 @@ legend-engine-xt-relationalStore-spanner org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-grammar/pom.xml index b68a26bcd5d..dba874f167b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-grammar/pom.xml @@ -3,7 +3,7 @@ legend-engine-xt-relationalStore-spanner org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-jdbc-shaded/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-jdbc-shaded/pom.xml index 28a8f27051f..e33f37e34d9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-jdbc-shaded/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-jdbc-shaded/pom.xml @@ -3,7 +3,7 @@ legend-engine-xt-relationalStore-spanner org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-protocol/pom.xml index b9cc029b116..74d8158bd7b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-protocol/pom.xml @@ -3,7 +3,7 @@ legend-engine-xt-relationalStore-spanner org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-pure/pom.xml index 1b5dc802126..62b5e5e39c0 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/legend-engine-xt-relationalStore-spanner-pure/pom.xml @@ -3,7 +3,7 @@ legend-engine-xt-relationalStore-spanner org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/pom.xml index 9bf609cca96..2817da7dcf4 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-spanner/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/legend-engine-xt-relationalStore-sparksql-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/legend-engine-xt-relationalStore-sparksql-pure/pom.xml index e102c7abd8f..f998b72c8b6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/legend-engine-xt-relationalStore-sparksql-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/legend-engine-xt-relationalStore-sparksql-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-sparksql - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/pom.xml index 0ff310c3eb6..f1d305b3c49 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sparksql/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-connection/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-connection/pom.xml index 59d17bafeb3..e7663e4a0dd 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-connection/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-connection/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-sqlserver - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution-tests/pom.xml index cafe566ea75..aa4e41fad28 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution-tests/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-sqlserver - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-relationalStore-sqlserver-execution-tests diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution/pom.xml index 9bd8e170d64..0a6442c40c8 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-sqlserver - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/pom.xml index 67f3ff45398..bc2777cac75 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-sqlserver - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -199,6 +199,10 @@ org.finos.legend.engine legend-engine-xt-relationalStore-core-pure + + org.finos.legend.engine + legend-engine-pure-functions-standard-pure + org.eclipse.collections diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver.definition.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver.definition.json index e617a0cf0e5..cc3922c472d 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver.definition.json +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver.definition.json @@ -6,6 +6,7 @@ "platform_store_relational", "core_functions_unclassified", "core", - "core_relational" + "core_relational", + "core_functions_standard" ] } \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/customSqlServerTests.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/customSqlServerTests.pure index a30266d21d4..fa5cd93e2c2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/customSqlServerTests.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/customSqlServerTests.pure @@ -31,6 +31,15 @@ function <> meta::relational::sqlServer::tests::testSqlGenerationDivi assertSameSQL($expectedSQL, $resultSqlServer); } +function <> meta::relational::sqlServer::tests::testReprocessGroupByAliasSQLServer():Boolean[1] +{ + let query = {|Trade.all() + ->groupBy([x | $x.id,x | $x.settlementDateTime],[agg(x | $x.quantity, y | $y->sum())],['id','settlementDateTime','quantity'])}; + + let sql = toSQLString($query, simpleRelationalMapping, meta::relational::runtime::DatabaseType.SqlServer, meta::relational::extension::relationalExtensions()); + assertEquals('select "root".ID as "id", "root".settlementDateTime as "settlementDateTime", sum("root".quantity) as "quantity" from tradeTable as "root" group by "root".ID,"root".settlementDateTime', $sql); +} + function <> meta::relational::sqlServer::tests::testToSQLStringConcatSQLServer():Boolean[1] { let s = toSQLString(|Person.all()->filter(p|$p.firstName == 'John') diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/sqlServerExtension.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/sqlServerExtension.pure index 0c3fdcee946..1e051222e41 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/sqlServerExtension.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/legend-engine-xt-relationalStore-sqlserver-pure/src/main/resources/core_relational_sqlserver/relational/sqlQueryToString/sqlServerExtension.pure @@ -41,7 +41,7 @@ function <> meta::relational::functions::sqlQueryToString::sqlSe literalProcessor = $literalProcessor, windowColumnProcessor = processWindowColumn_WindowColumn_1__SqlGenerationContext_1__String_1_, joinStringsProcessor = processJoinStringsOperationForSqlServer_JoinStrings_1__SqlGenerationContext_1__String_1_, - selectSQLQueryProcessor = processSelectSQLQueryDefault_SelectSQLQuery_1__SqlGenerationContext_1__Boolean_1__String_1_, + selectSQLQueryProcessor = processSelectSQLQueryForSQLServer_SelectSQLQuery_1__SqlGenerationContext_1__Boolean_1__String_1_, columnNameToIdentifier = columnNameToIdentifierDefault_String_1__DbConfig_1__String_1_, identifierProcessor = processIdentifierWithDoubleQuotes_String_1__DbConfig_1__String_1_, dynaFuncDispatch = $dynaFuncDispatch, @@ -49,6 +49,27 @@ function <> meta::relational::functions::sqlQueryToString::sqlSe ); } +function meta::relational::functions::sqlQueryToString::sqlServer::processSelectSQLQueryForSQLServer(s:SelectSQLQuery[1], sgc:SqlGenerationContext[1], isSubSelect:Boolean[1]):String[1] +{ + $s->processSelectSQLQueryForSQLServer($sgc.dbConfig, $sgc.format, $sgc.config, $isSubSelect, $sgc.extensions); +} + +function <> meta::relational::functions::sqlQueryToString::sqlServer::processSelectSQLQueryForSQLServer(s:SelectSQLQuery[1], dbConfig : DbConfig[1], format:Format[1], config:Config[1], isSubSelect : Boolean[1], extensions:Extension[*]):String[1] +{ + assertEmpty($s.pivot, 'pivot is not supported'); + let opStr = if($s.filteringOperation->isEmpty(), |'', |$s.filteringOperation->map(s|$s->processOperation($dbConfig, $format->indent(), ^$config(callingFromFilter = true), $extensions))->filter(s|$s != '')->joinStrings(' <||> ')); + let havingStr = if($s.havingOperation->isEmpty(), |'', |$s.havingOperation->map(s|$s->processOperation($dbConfig, $format->indent(), $config, $extensions))->filter(s|$s != '')->joinStrings(' <||> ')); + + $format.separator + 'select ' + processTop($s, $format, $dbConfig, $extensions) + if($s.distinct == true,|'distinct ',|'') + + processSelectColumns($s.columns, $dbConfig, $format->indent(), true, $extensions) + + if($s.data == [],|'',| ' ' + $format.separator + 'from ' + $s.data->toOne()->processJoinTreeNode([], $dbConfig, $format->indent(), [], $extensions)) + + if (eq($opStr, ''), |'', | ' ' + $format.separator + 'where ' + $opStr) + + if ($s.groupBy->isEmpty(),|'',| ' ' + $format.separator + 'group by '+$s.groupBy->processGroupByColumns($dbConfig, $format->indent(), false, $extensions)->makeString(','))+ + if (eq($havingStr, ''), |'', | ' ' + $format.separator + 'having ' + $havingStr) + + if ($s.orderBy->isEmpty(),|'',| ' ' + $format.separator + 'order by '+ $s.orderBy->processOrderBy($dbConfig, $format->indent(), $config, $extensions)->makeString(','))+ + + processLimit($s, $dbConfig, $format, $extensions, [], processSliceOrDropDefault_SelectSQLQuery_1__Format_1__DbConfig_1__Extension_MANY__Any_1__String_1_); +} + function <> meta::relational::functions::sqlQueryToString::sqlServer::getDynaFunctionToSqlForSqlServer(): DynaFunctionToSql[*] { let allStates = allGenerationStates(); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/pom.xml index 47cebc27313..59f0fb0eae2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sqlserver/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/legend-engine-xt-relationalStore-sybase-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/legend-engine-xt-relationalStore-sybase-pure/pom.xml index b1ac462e1d9..10e72d29941 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/legend-engine-xt-relationalStore-sybase-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/legend-engine-xt-relationalStore-sybase-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-sybase - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/pom.xml index b5f9ad725f1..99377a7c24e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybase/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/legend-engine-xt-relationalStore-sybaseiq-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/legend-engine-xt-relationalStore-sybaseiq-pure/pom.xml index 3c4c467412c..e3828fbc0c4 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/legend-engine-xt-relationalStore-sybaseiq-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/legend-engine-xt-relationalStore-sybaseiq-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-sybaseiq - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/pom.xml index 1356c8e879e..7bf5fde7c5b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-sybaseiq/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution-tests/pom.xml index e13093dcfba..d0e91af70b5 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution-tests/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-trino - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution/pom.xml index c69821ebcdb..58713cb1dc7 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-execution/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-trino - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-grammar/pom.xml index 4fa113e5eb7..d07dc5ab9e7 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-trino - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-protocol/pom.xml index 08cea1dfa8e..c380bc4bc56 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-trino - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-pure/pom.xml index ee30af5dca5..19c2e080dfb 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/legend-engine-xt-relationalStore-trino-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-trino - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/pom.xml index b920a8d60dd..c7e4d4a2d48 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-trino/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-dbExtension - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/pom.xml index 1bc56b7fb9e..e350f2ced3a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-relationalStore - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-authorizer/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-authorizer/pom.xml index b40189f653f..e21f8a8eba9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-authorizer/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-authorizer/pom.xml @@ -3,7 +3,7 @@ legend-engine-xt-relationalStore-execution org.finos.legend.engine - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication-default/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication-default/pom.xml index f09551ddc59..cd3ece67133 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication-default/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication-default/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-relationalStore-executionPlan-connection-authentication-default diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication/pom.xml index f019a305774..eff3aad1e10 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-authentication/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 legend-engine-xt-relationalStore-executionPlan-connection-authentication diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-tests/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-tests/pom.xml index 11db307b8ec..d65f82a68f9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-tests/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection-tests/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/pom.xml index 8c086e1b363..04a272573ad 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-connection/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-http-api/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-http-api/pom.xml index bb47e99c958..8225256cd57 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-http-api/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/pom.xml index eacc01aa8df..09922fb9122 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -294,11 +294,6 @@ legend-pure-m2-dsl-mapping-grammar test - - org.finos.legend.engine - legend-engine-configuration-contract-extension-pure - test - org.finos.legend.engine legend-engine-xt-javaPlatformBinding-pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RealizedRelationalResult.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RealizedRelationalResult.java index fe0ac2d20e5..e2a33977b24 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RealizedRelationalResult.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RealizedRelationalResult.java @@ -38,8 +38,6 @@ public class RealizedRelationalResult extends StreamingResult public List columns; public List> resultSetRows; public List> transformedRows; - - private static final int DEFAULT_ROW_LIMIT = 1000; public static final String ROW_LIMIT_PROPERTY_NAME = "org.finos.legend.engine.realizedRelationalResultRowLimit"; public RealizedRelationalResult(RelationalResult relationalResult) throws SQLException @@ -52,7 +50,7 @@ public RealizedRelationalResult(RelationalResult relationalResult) throws SQLExc this.transformedRows = Lists.mutable.empty(); this.resultSetRows = Lists.mutable.empty(); ResultSet resultSet = relationalResult.resultSet; - int SUPPORTED_RESULT_ROWS = getRowLimit(); + long SUPPORTED_RESULT_ROWS = getRealizeRowLimit(); int rowCount = 0; try { @@ -84,11 +82,6 @@ public RealizedRelationalResult(RelationalResult relationalResult) throws SQLExc } } - public int getRowLimit() - { - return Integer.getInteger(ROW_LIMIT_PROPERTY_NAME, DEFAULT_ROW_LIMIT); - } - private RealizedRelationalResult() { super(Lists.mutable.empty()); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResult.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResult.java index ff1394aa737..7cf5b37d315 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResult.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResult.java @@ -600,7 +600,7 @@ public Result realizeInMemory() } catch (SQLException e) { - return new ErrorResult(-1, "Error realizing the relational result in memory : " + e.getMessage()); + throw new RuntimeException("Failed to realize in memory", e); } } @@ -719,4 +719,4 @@ public List getResultSetColumns() throw new RuntimeException(e); } } -} \ No newline at end of file +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResultGridPrintUtility.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResultGridPrintUtility.java new file mode 100644 index 00000000000..c4e8e8114b7 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResultGridPrintUtility.java @@ -0,0 +1,195 @@ +// Copyright 2024 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. +// + +package org.finos.legend.engine.plan.execution.stores.relational.result; + +import java.sql.ResultSet; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.factory.Lists; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.result.SQLResultColumn; + +public class RelationalResultGridPrintUtility +{ + public static String prettyGridPrint(ResultSet resultSet, List columnNames, List columnTypes, int maxRowSize, int maxColSize) + { + List> values = Lists.mutable.empty(); + + try + { + + // collect data + for (int i = 0; i < columnNames.size(); i++) + { + values.add(Lists.mutable.empty()); + } + while (resultSet.next()) + { + for (int i = 1; i <= columnNames.size(); i++) + { + String value = resultSet.getObject(i) == null ? "" : resultSet.getObject(i).toString(); + values.get(i - 1).add(value); + } + } + + return prettyGridPrint(columnNames, columnTypes, maxRowSize, maxColSize, values); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + public static String prettyGridPrint(RelationalResult relationalResult, int maxRowSize, int maxColSize) + { + try (ResultSet rs = relationalResult.resultSet) + { + return prettyGridPrint(rs, relationalResult.sqlColumns, ListIterate.collect(relationalResult.getSQLResultColumns(), col -> col.dataType), maxRowSize, maxColSize); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + public static String prettyGridPrint(RealizedRelationalResult resultSet, int maxRowSize, int maxColSize) + { + List> data = resultSet.transformedRows; + List columnNames = resultSet.columns.stream().map(SQLResultColumn::getNonQuotedLabel).collect(Collectors.toList()); + List columnTypes = resultSet.columns.stream().map(x -> x.dataType).collect(Collectors.toList()); + + + List> rows = Lists.mutable.empty(); + + // collect data in columnar fashion + for (int i = 0; i < columnNames.size(); i++) + { + rows.add(Lists.mutable.empty()); + } + for (List row : data) + { + for (int i = 0; i < columnNames.size(); i++) + { + rows.get(i).add(row.get(i)); + } + } + + return prettyGridPrint(columnNames, columnTypes, maxRowSize, maxColSize, rows); + } + + private static String prettyGridPrint(List columnNames, List columnTypes, int maxRowSize, int maxColSize, List> values) + { + int columnCount = columnNames.size(); + + MutableList size = Lists.mutable.empty(); + + // determine the max size for each column + for (int i = 0; i < columnCount; i++) + { + int currMax = Math.max(columnNames.get(i).length(), columnTypes.get(i).length()); + size.add(Lists.adapt(values.get(i)).injectInto(currMax, (IntObjectToIntFunction) (a, b) -> Math.max(Objects.toString(b).length(), a))); + } + size = Lists.mutable.withAll(size.collect(s -> Math.min(maxColSize, s + 2))); + + // print the result + StringBuilder builder = new StringBuilder(); + + drawSeparation(builder, columnCount, size); + drawRow(builder, columnCount, size, columnNames::get, maxColSize); + drawRow(builder, columnCount, size, columnTypes::get, maxColSize); + drawSeparation(builder, columnCount, size); + + int rows = values.get(0).size(); + if (rows <= maxRowSize) + { + for (int k = 0; k < rows; k++) + { + final int fk = k; + drawRow(builder, columnCount, size, i -> Objects.toString(values.get(i).get(fk)), maxColSize); + } + } + else + { + int topRows = (int) Math.ceil((float) maxRowSize / 2); + int bottomRows = maxRowSize - topRows; + for (int k = 0; k < topRows; k++) + { + final int fk = k; + drawRow(builder, columnCount, size, i -> Objects.toString(values.get(i).get(fk)), maxColSize); + } + for (int k = 0; k < 3; k++) + { + drawRow(builder, columnCount, size, i -> ".", maxColSize); + } + for (int k = rows - bottomRows; k < rows; k++) + { + final int fk = k; + drawRow(builder, columnCount, size, i -> Objects.toString(values.get(i).get(fk)), maxColSize); + } + } + + + drawSeparation(builder, columnCount, size); + + // add summary + builder.append(rows).append(" rows ").append(rows > maxRowSize ? ("(" + maxRowSize + " shown) ") : "").append("-- ").append(columnCount).append(" columns"); + return builder.toString(); + } + + private static void drawSeparation(StringBuilder builder, int count, MutableList size) + { + builder.append("+"); + for (int i = 0; i < count; i++) + { + repeat('-', size.get(i), builder); + builder.append("+"); + } + builder.append("\n"); + } + + private static void repeat(char value, int length, StringBuilder builder) + { + for (int k = 0; k < length; k++) + { + builder.append(value); + } + } + + private static void drawRow(StringBuilder builder, int count, MutableList size, Function getter, int maxColSize) + { + builder.append("|"); + for (int i = 0; i < count; i++) + { + String val = printValue(getter.apply(i), maxColSize); + int space = (size.get(i) - val.length()) / 2; + repeat(' ', space, builder); + builder.append(val); + repeat(' ', size.get(i) - val.length() - space, builder); + builder.append("|"); + } + + builder.append("\n"); + } + + private static String printValue(String str, int max) + { + return str.length() > max ? str.substring(0, max - 3) + "..." : str; + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/result/TestRelationalResultGridPrintUtility.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/result/TestRelationalResultGridPrintUtility.java new file mode 100644 index 00000000000..19e32bd7690 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/result/TestRelationalResultGridPrintUtility.java @@ -0,0 +1,149 @@ +// Copyright 2024 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. +// + +package org.finos.legend.engine.plan.execution.stores.relational.result; + +import java.sql.SQLException; +import java.sql.Statement; +import org.eclipse.collections.impl.factory.Maps; +import org.finos.legend.engine.plan.execution.stores.relational.connection.AlloyTestServer; +import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan; +import org.junit.Assert; +import org.junit.Test; + +public class TestRelationalResultGridPrintUtility extends AlloyTestServer +{ + @Test + public void prettyPrintRelationalResult() + { + Assert.assertEquals( + "+----+----+\n" + + "|name|i...|\n" + + "|V...|V...|\n" + + "+----+----+\n" + + "|R...|RBH |\n" + + "| . | . |\n" + + "| . | . |\n" + + "| . | . |\n" + + "|E...|ERP |\n" + + "+----+----+\n" + + "4 rows (2 shown) -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(execute(), 2, 4) + ); + Assert.assertEquals( + "+------+------+\n" + + "| name |ini...|\n" + + "|VAR...|VAR...|\n" + + "+------+------+\n" + + "|Rafael| RBH |\n" + + "| Jose | JJS |\n" + + "| Juan | JHS |\n" + + "|Enr...| ERP |\n" + + "+------+------+\n" + + "4 rows -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(execute(), 10, 6) + ); + } + + @Test + public void prettyPrintRealizeRelationalResult() + { + RelationalResult result = execute(); + RealizedRelationalResult realizeInMemory = (RealizedRelationalResult) result.realizeInMemory(); + + Assert.assertEquals( + "+----+----+\n" + + "|name|i...|\n" + + "|V...|V...|\n" + + "+----+----+\n" + + "|R...|RBH |\n" + + "| . | . |\n" + + "| . | . |\n" + + "| . | . |\n" + + "|E...|ERP |\n" + + "+----+----+\n" + + "4 rows (2 shown) -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(realizeInMemory, 2, 4) + ); + Assert.assertEquals( + "+------+------+\n" + + "| name |ini...|\n" + + "|VAR...|VAR...|\n" + + "+------+------+\n" + + "|Rafael| RBH |\n" + + "| Jose | JJS |\n" + + "| Juan | JHS |\n" + + "|Enr...| ERP |\n" + + "+------+------+\n" + + "4 rows -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(realizeInMemory, 10, 6) + ); + } + + private RelationalResult execute() + { + String func = "function local::func(): Any[*]{ |#>{local::db.person}#->select()->from(test::Runtime) }"; + String db = "###Relational\n" + + "Database local::db" + + "(" + + " Table person" + + "(" + + "name varchar(100)," + + "initials varchar(100)" + + ")" + + ")"; + + String mapping = "###Mapping\n" + + "Mapping test::Map()"; + + String runtime = "###Runtime\n" + + "Runtime test::Runtime\n" + + "{\n" + + " mappings:\n" + + " [\n" + + " ];\n" + + " connections:\n" + + " [\n" + + " local::db:\n" + + " [\n" + + " c1: #{\n" + + " RelationalDatabaseConnection\n" + + " {\n" + + " type: H2;\n" + + " specification: LocalH2 {};\n" + + " auth: DefaultH2;\n" + + " }\n" + + " }#\n" + + " ]\n" + + " ];\n" + + "}\n"; + + SingleExecutionPlan singleExecutionPlan = this.buildPlan(func + "\n" + db + "\n" + runtime + "\n" + mapping); + RelationalResult result = (RelationalResult) planExecutor.execute(singleExecutionPlan, Maps.mutable.empty(), null); + return result; + } + + @Override + protected void insertTestData(Statement s) throws SQLException + { + s.execute("Create Schema default;"); + s.execute("Drop table if exists person;"); + s.execute("Create Table person(name VARCHAR(100) NOT NULL, INITIALS VARCHAR(10));"); + s.execute("insert into person (name, initials) values ('Rafael', 'RBH');"); + s.execute("insert into person (name, initials) values ('Jose', 'JJS');"); + s.execute("insert into person (name, initials) values ('Juan', 'JHS');"); + s.execute("insert into person (name, initials) values ('Enrique', 'ERP');"); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-h2-1.4.200-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-h2-1.4.200-execution/pom.xml index 6066a417865..073cfe44a0a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-h2-1.4.200-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-h2-1.4.200-execution/pom.xml @@ -20,7 +20,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-execution - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/pom.xml index 17193d03f50..d0bad7e481a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/pom.xml @@ -18,7 +18,7 @@ org.finos.legend.engine legend-engine-xts-relationalStore - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/pom.xml index 2ba922e7432..c853e63d841 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java index 7b782f286af..326fd2bc8a6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalBuilder.java @@ -606,14 +606,20 @@ private static MutableList collectJoins(JoinTreeNode joinTreeNode, Mutable return results; } - public static org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.Join processDatabaseJoin(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Join srcJoin, CompileContext context, Database database) + public static org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.Join processDatabaseJoinFirstPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Join srcJoin, CompileContext context, Database database) { + return new Root_meta_relational_metamodel_join_Join_Impl(srcJoin.name, SourceInformationHelper.toM3SourceInformation(srcJoin.sourceInformation), context.pureModel.getClass(M2RelationalPaths.Join)) + ._name(srcJoin.name) + ._database(database); + } + + public static void processDatabaseJoinSecondPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Join srcJoin, CompileContext context, Database database, int index) + { + Join join = database._joins().toList().get(index); MutableMap aliasMap = MapAdapter.adapt(new LinkedHashMap<>()); MutableList selfJoinTargets = Lists.mutable.empty(); Operation op = (Operation) processRelationalOperationElement(srcJoin.operation, context, aliasMap, selfJoinTargets); MutableList aliases = Lists.mutable.withAll(aliasMap.values()); - Join join = new Root_meta_relational_metamodel_join_Join_Impl(srcJoin.name, SourceInformationHelper.toM3SourceInformation(srcJoin.sourceInformation), context.pureModel.getClass(M2RelationalPaths.Join)) - ._name(srcJoin.name); if (aliases.size() == 2) { join._target(aliases.select(tableAlias -> tableAlias._name().equals(srcJoin.target)).getLast()); @@ -672,22 +678,23 @@ public static org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.jo ._first(aliases.get(1)) ._second(aliases.get(0)) ) - )._database(database) - ._operation(op); - return join; + )._operation(op); } - public static Filter processDatabaseFilter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Filter srcFilter, CompileContext context, Database database) + public static Filter processDatabaseFilterFirstPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Filter srcFilter, CompileContext context, Database database) { org.finos.legend.pure.m4.coreinstance.SourceInformation m3SourceInformation = SourceInformationHelper.toM3SourceInformation(srcFilter.sourceInformation); + Filter filter = "multigrain".equals(srcFilter._type) ? new Root_meta_relational_metamodel_MultiGrainFilter_Impl(srcFilter.name, m3SourceInformation, context.pureModel.getClass("meta::relational::metamodel::MultiGrainFilter")) : new Root_meta_relational_metamodel_Filter_Impl(srcFilter.name, m3SourceInformation, context.pureModel.getClass("meta::relational::metamodel::Filter")); + return filter._name(srcFilter.name) + ._database(database); + } + + public static void processDatabaseFilterSecondPass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Filter srcFilter, CompileContext context, Database database, int index) + { + Filter filter = database._filters().toList().get(index); MutableMap aliasMap = Maps.mutable.empty(); Operation op = (Operation) processRelationalOperationElement(srcFilter.operation, context, aliasMap, Lists.mutable.empty()); - Filter filter = "multigrain".equals(srcFilter._type) ? new Root_meta_relational_metamodel_MultiGrainFilter_Impl(srcFilter.name, m3SourceInformation, context.pureModel.getClass("meta::relational::metamodel::MultiGrainFilter")) : new Root_meta_relational_metamodel_Filter_Impl(srcFilter.name, m3SourceInformation, context.pureModel.getClass("meta::relational::metamodel::Filter")); - filter - ._name(srcFilter.name) - ._database(database) - ._operation(op); - return filter; + filter._operation(op); } private static org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.datatype.DataType transformDatabaseDataType(DataType dataType, CompileContext context) diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalDatabaseConnectionBuilder.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalDatabaseConnectionBuilder.java index 76c03b32b89..4b06754cf94 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalDatabaseConnectionBuilder.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperRelationalDatabaseConnectionBuilder.java @@ -58,7 +58,7 @@ public static void addDatabaseConnectionProperties(Root_meta_external_store_rela Database db = new Database(); db.name = element; db._package = ""; - new PackageableElementFirstPassBuilder(context).visit(db); + context.processFirstPass(db); } } } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/RelationalCompilerExtension.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/RelationalCompilerExtension.java index 7cc4930c94e..5738b689924 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/RelationalCompilerExtension.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/RelationalCompilerExtension.java @@ -30,6 +30,7 @@ import org.eclipse.collections.api.set.SetIterable; import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.list.mutable.FastList; +import org.eclipse.collections.impl.multimap.list.FastListMultimap; import org.eclipse.collections.impl.tuple.Tuples; import org.eclipse.collections.impl.utility.Iterate; import org.eclipse.collections.impl.utility.ListIterate; @@ -76,6 +77,8 @@ import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RootRelationalClassMapping; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.mappingTest.RelationalInputData; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Database; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Filter; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.Join; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.DatabaseInstance; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.executionContext.RelationalExecutionContext; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.relation.RelationStoreAccessor; @@ -183,7 +186,9 @@ public Iterable> getExtraProcessors() org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database database = new Root_meta_relational_metamodel_Database_Impl(srcDatabase.name, SourceInformationHelper.toM3SourceInformation(srcDatabase.sourceInformation), null)._name(srcDatabase.name); database._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("", null, context.pureModel.getClass("meta::pure::metamodel::type::generics::GenericType")) - ._rawType(context.pureModel.getType("meta::relational::metamodel::Database"))); + ._rawType(context.pureModel.getType("meta::relational::metamodel::Database"))) + ._stereotypes(srcDatabase.stereotypes == null ? Lists.fixedSize.empty() : ListIterate.collect(srcDatabase.stereotypes, stereotypePointer -> context.resolveStereotype(stereotypePointer.profile, stereotypePointer.value, stereotypePointer.profileSourceInformation, stereotypePointer.sourceInformation))); + return database; }, (Database srcDatabase, CompileContext context) -> @@ -194,24 +199,35 @@ public Iterable> getExtraProcessors() database._includes(ListIterate.collect(srcDatabase.includedStores, include -> HelperRelationalBuilder.resolveDatabase(context.pureModel.addPrefixToTypeReference(include.path), include.sourceInformation, context))); } database._schemas(ListIterate.collect(srcDatabase.schemas, _schema -> HelperRelationalBuilder.processDatabaseSchema(_schema, context, database))); - }, - (Database srcDatabase, CompileContext context) -> - { - org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database database = HelperRelationalBuilder.getDatabase(context.pureModel.buildPackageString(srcDatabase._package, srcDatabase.name), srcDatabase.sourceInformation, context); ListIterate.forEach(srcDatabase.schemas, _schema -> HelperRelationalBuilder.processDatabaseSchemaViewsFirstPass(_schema, context, database)); + checkForDuplicateJoins(srcDatabase, context); + checkForDuplicateFilters(srcDatabase, context); + database._joins(srcDatabase.joins == null ? Lists.fixedSize.empty() : ListIterate.collect(srcDatabase.joins, join -> HelperRelationalBuilder.processDatabaseJoinFirstPass(join, context, database))) + ._filters(srcDatabase.filters == null ? Lists.fixedSize.empty() : ListIterate.collect(srcDatabase.filters, filter -> HelperRelationalBuilder.processDatabaseFilterFirstPass(filter, context, database))); }, (Database srcDatabase, CompileContext context) -> { org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database database = HelperRelationalBuilder.getDatabase(context.pureModel.buildPackageString(srcDatabase._package, srcDatabase.name), srcDatabase.sourceInformation, context); - // TODO checkForDuplicatesByName for filters/joins - database._joins(srcDatabase.joins == null ? Lists.fixedSize.empty() : ListIterate.collect(srcDatabase.joins, join -> HelperRelationalBuilder.processDatabaseJoin(join, context, database))) - ._filters(srcDatabase.filters == null ? Lists.fixedSize.empty() : ListIterate.collect(srcDatabase.filters, filter -> HelperRelationalBuilder.processDatabaseFilter(filter, context, database))) - ._stereotypes(srcDatabase.stereotypes == null ? Lists.fixedSize.empty() : ListIterate.collect(srcDatabase.stereotypes, stereotypePointer -> context.resolveStereotype(stereotypePointer.profile, stereotypePointer.value, stereotypePointer.profileSourceInformation, stereotypePointer.sourceInformation))); + if (srcDatabase.joins != null) + { + for (int i = 0; i < srcDatabase.joins.size(); i++) + { + HelperRelationalBuilder.processDatabaseJoinSecondPass(srcDatabase.joins.get(i), context, database, i); + } + } + if (srcDatabase.filters != null) + { + for (int i = 0; i < srcDatabase.filters.size(); i++) + { + HelperRelationalBuilder.processDatabaseFilterSecondPass(srcDatabase.filters.get(i), context, database, i); + } + } + ListIterate.forEach(srcDatabase.schemas, _schema -> HelperRelationalBuilder.processDatabaseSchemaViewsSecondPass(_schema, context, database)); }, (Database srcDatabase, CompileContext context) -> { org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database database = HelperRelationalBuilder.getDatabase(context.pureModel.buildPackageString(srcDatabase._package, srcDatabase.name), srcDatabase.sourceInformation, context); - ListIterate.forEach(srcDatabase.schemas, _schema -> HelperRelationalBuilder.processDatabaseSchemaViewsSecondPass(_schema, context, database)); + return database._includes(); } ), Processor.newProcessor( @@ -847,6 +863,44 @@ public List, CompileContext>> getExtra }); } + private void checkForDuplicateJoins(Database srcDatabase, CompileContext context) + { + List warnings = Lists.mutable.empty(); + if (srcDatabase.joins != null) + { + FastListMultimap nameToJoins = ListIterate.groupBy(srcDatabase.joins, join -> join.name); + nameToJoins.forEachKey(name -> + { + MutableList joins = nameToJoins.get(name); + if (joins.size() > 1) + { + joins.forEach(join -> warnings.add(new Warning(join.sourceInformation, "Found joins with duplicate names: " + name))); + } + }); + } + + context.pureModel.addWarnings(warnings); + } + + private void checkForDuplicateFilters(Database srcDatabase, CompileContext context) + { + List warnings = Lists.mutable.empty(); + if (srcDatabase.filters != null) + { + FastListMultimap nameToFilters = ListIterate.groupBy(srcDatabase.filters, filter -> filter.name); + nameToFilters.forEachKey(name -> + { + MutableList filters = nameToFilters.get(name); + if (filters.size() > 1) + { + filters.forEach(filter -> warnings.add(new Warning(filter.sourceInformation, "Found filters with duplicate names: " + name))); + } + }); + } + + context.pureModel.addWarnings(warnings); + } + private static void checkForDuplicates(List list) { List duplicates = list.stream() diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java index c313f8f454c..e5c9a80a8a6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java @@ -35,6 +35,7 @@ import org.junit.Test; import java.util.Arrays; +import java.util.Collections; public class TestRelationalCompilationFromGrammar extends TestCompilationFromGrammar.TestCompilationFromGrammarTestSuite { @@ -2761,4 +2762,85 @@ public void testMappingToPropertyWithDerivedPropertyConflict() " }\n" + ")\n"); } + + @Test + public void testFilterFromNonIncludedDatabase() + { + test("###Relational\n" + + "Database app::myDb\n" + + "(\n" + + " include app::dbInc\n" + + " Table myTable(EVENT_ID INT PRIMARY KEY, trade_id INT, eventType VARCHAR(10), eventDate DATE, person_id INT)\n" + + " View myView\n" + + " (\n" + + " maxTradeEventDate : max(myTable.eventDate)\n" + + " )\n" + + " Filter EventFilter(myTable.eventType = 'myevent')\n" + + ")\n\n" + + "Database app::dbInc\n" + + "(\n" + + " Table tradeEventTable(EVENT_ID INT PRIMARY KEY, trade_id INT, eventType VARCHAR(10), eventDate DATE, person_id INT)\n" + + " View tradeEventViewMaxTradeEventDate\n" + + " (\n" + + " ~filter [app::myDb]EventFilter\n" + + " maxTradeEventDate : max(tradeEventTable.eventDate)\n" + + " )\n" + + ")"); + } + + @Test + public void testDuplicateNameForJoins() + { + test("###Relational\n" + + "Database simple::dbInc\n" + + "(\n" + + " Table personTable\n" + + " (\n" + + " ID INTEGER PRIMARY KEY,\n" + + " FIRSTNAME VARCHAR(200),\n" + + " LASTNAME VARCHAR(200),\n" + + " AGE INTEGER,\n" + + " ADDRESSID INTEGER,\n" + + " FIRMID INTEGER,\n" + + " MANAGERID INTEGER\n" + + " )\n" + + " Table firmTable\n" + + " (\n" + + " ID INTEGER PRIMARY KEY,\n" + + " LEGALNAME VARCHAR(200),\n" + + " ADDRESSID INTEGER,\n" + + " CEOID INTEGER\n" + + " )\n" + + " Join Firm_Person(firmTable.ID = personTable.FIRMID)\n" + + " Join Firm_Person(firmTable.ADDRESSID = personTable.ADDRESSID)\n" + + ")", null, Arrays.asList("COMPILATION error at [21:3-53]: Found joins with duplicate names: Firm_Person", "COMPILATION error at [22:3-63]: Found joins with duplicate names: Firm_Person")); + } + + @Test + public void testDuplicateNameForFilters() + { + test("###Relational\n" + + "Database simple::dbInc\n" + + "(\n" + + " Table personTable\n" + + " (\n" + + " ID INTEGER PRIMARY KEY,\n" + + " FIRSTNAME VARCHAR(200),\n" + + " LASTNAME VARCHAR(200),\n" + + " AGE INTEGER,\n" + + " ADDRESSID INTEGER,\n" + + " FIRMID INTEGER,\n" + + " MANAGERID INTEGER\n" + + " )\n" + + " Table firmTable\n" + + " (\n" + + " ID INTEGER PRIMARY KEY,\n" + + " LEGALNAME VARCHAR(200),\n" + + " ADDRESSID INTEGER,\n" + + " CEOID INTEGER\n" + + " )\n" + + " Filter FirmFilter(firmTable.LEGALNAME = 'myevent')\n" + + " Filter FirmFilter(firmTable.ADDRESSID = 1)\n" + + ")", null, Arrays.asList("COMPILATION error at [21:3-52]: Found filters with duplicate names: FirmFilter", "COMPILATION error at [22:3-44]: Found filters with duplicate names: FirmFilter")); + } } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/pom.xml index bfadb2c2da4..ccbeca963c4 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-http-api/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/pom.xml new file mode 100644 index 00000000000..39e37f97bdf --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/pom.xml @@ -0,0 +1,79 @@ + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSql + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-pure-functions-relationalStore-postgresSql-parser + jar + Legend Engine - Pure - Functions - Relational Store - Postgres SQL - Parser + + + + + org.finos.legend.pure + legend-pure-maven-generation-par + + + generate-sources + + build-pure-jar + + + src/main/resources + ${legend.pure.version} + + + ${project.basedir}/src/main/resources/core_external_store_relational_postgres_sql_parser.definition.json + + + + + + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + ${project.version} + + + + + + + + + org.finos.legend.pure + legend-pure-m3-core + + + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/code/core/CoreExternalStoreRelationalPostgresSqlParserCodeRepositoryProvider.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/code/core/CoreExternalStoreRelationalPostgresSqlParserCodeRepositoryProvider.java new file mode 100644 index 00000000000..0b5cffc084f --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/code/core/CoreExternalStoreRelationalPostgresSqlParserCodeRepositoryProvider.java @@ -0,0 +1,28 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.code.core; + +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepository; +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider; +import org.finos.legend.pure.m3.serialization.filesystem.repository.GenericCodeRepository; + +public class CoreExternalStoreRelationalPostgresSqlParserCodeRepositoryProvider implements CodeRepositoryProvider +{ + @Override + public CodeRepository repository() + { + return GenericCodeRepository.build("core_external_store_relational_postgres_sql_parser.definition.json"); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider new file mode 100644 index 00000000000..3399dbeeec4 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider @@ -0,0 +1 @@ +org.finos.legend.engine.code.core.CoreExternalStoreRelationalPostgresSqlParserCodeRepositoryProvider \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/core_external_store_relational_postgres_sql_parser.definition.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/core_external_store_relational_postgres_sql_parser.definition.json new file mode 100644 index 00000000000..14c6bc90c7d --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/core_external_store_relational_postgres_sql_parser.definition.json @@ -0,0 +1,18 @@ +{ + "name": "core_external_store_relational_postgres_sql_parser", + "pattern": "(meta::external::store::relational::postgresSql::parser)(::.*)?", + "dependencies": [ + "platform", + "platform_dsl_store", + "platform_dsl_mapping", + "platform_dsl_path", + "platform_dsl_graph", + "platform_dsl_diagram", + "platform_store_relational", + "core_functions_standard", + "core_functions_unclassified", + "core_functions_json", + "core", + "core_external_store_relational_postgres_sql_model" + ] +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/core_external_store_relational_postgres_sql_parser/postgresSqlParser.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/core_external_store_relational_postgres_sql_parser/postgresSqlParser.pure new file mode 100644 index 00000000000..617d291673c --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-functions-relationalStore-postgresSql-parser/src/main/resources/core_external_store_relational_postgres_sql_parser/postgresSqlParser.pure @@ -0,0 +1,52 @@ +// Copyright 2024 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 meta::external::query::sql::metamodel::*; +import meta::external::store::relational::postgresSql::parser::*; +import meta::pure::functions::meta::*; +import meta::json::*; + +native function <> meta::external::store::relational::postgresSql::parser::parseSqlStatementToJson(sql: String[1]): String[1]; + +function meta::external::store::relational::postgresSql::parser::parseSqlStatement(sql: String[1]): Statement[1] +{ + let statementJson = $sql->parseSqlStatementToJson(); + $statementJson->fromJSON( + Statement, + ^JSONDeserializationConfig( + typeKeyName = '_type', + failOnUnknownProperties = true, + typeLookup = typeLookupPairs() + ) + ); +} + +function <> meta::external::store::relational::postgresSql::parser::typeLookupPairs(): Pair[*] +{ + getAllPackageElements(meta::external::query::sql::metamodel, false) + ->filter(x | $x->instanceOf(Class)) + ->cast(@Class) + ->map(x | pair($x.name->toLowerFirstCharacter()->toOne(), $x->elementToPath())) +} + +function <> meta::external::store::relational::postgresSql::parser::testParseSqlStatement(): Boolean[1] +{ + let statement = parseSqlStatement('SELECT 1 + 2 as result'); + assert($statement->instanceOf(Query)); + assert($statement->cast(@Query).queryBody->instanceOf(QuerySpecification)); + assert($statement->cast(@Query).queryBody->cast(@QuerySpecification).select.selectItems->size() == 1); + assert($statement->cast(@Query).queryBody->cast(@QuerySpecification).select.selectItems->toOne()->instanceOf(SingleColumn)); + assert($statement->cast(@Query).queryBody->cast(@QuerySpecification).select.selectItems->toOne()->cast(@SingleColumn).alias == 'result'); + assert($statement->cast(@Query).queryBody->cast(@QuerySpecification).select.selectItems->toOne()->cast(@SingleColumn).expression->instanceOf(ArithmeticExpression)); +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/pom.xml new file mode 100644 index 00000000000..a4121c4941d --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/pom.xml @@ -0,0 +1,154 @@ + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSql + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser + jar + Legend Engine - Pure - Runtime - Java Extension - Compiled - Functions - Relational Store - Postgres SQL - Parser + + + + + org.finos.legend.pure + legend-pure-maven-generation-java + + + compile + + build-pure-compiled-jar + + + true + true + modular + true + + core_external_store_relational_postgres_sql_parser + + + + + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-pure-functions-relationalStore-postgresSql-parser + ${project.version} + + + + + + + + + + org.finos.legend.pure + legend-pure-m4 + + + org.finos.legend.pure + legend-pure-m3-core + + + org.finos.legend.pure + legend-pure-runtime-java-engine-compiled + + + + + + org.finos.legend.engine + legend-engine-pure-platform-java + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-unclassified + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-json + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSql-protocol + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSql-grammar + + + org.finos.legend.engine + legend-engine-pure-functions-relationalStore-postgresSql-parser + runtime + + + + + org.eclipse.collections + eclipse-collections + + + org.eclipse.collections + eclipse-collections-api + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + + + junit + junit + + + + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/PostgresSqlParserExtensionCompiled.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/PostgresSqlParserExtensionCompiled.java new file mode 100644 index 00000000000..77910a97f06 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/PostgresSqlParserExtensionCompiled.java @@ -0,0 +1,45 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.compiled; + +import org.eclipse.collections.api.factory.Lists; +import org.finos.legend.pure.runtime.java.compiled.extension.AbstractCompiledExtension; +import org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension; +import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.Native; +import org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.compiled.natives.ParseSqlStatementToJson; + +import java.util.List; + +public class PostgresSqlParserExtensionCompiled extends AbstractCompiledExtension +{ + @Override + public List getExtraNatives() + { + return Lists.fixedSize.with( + new ParseSqlStatementToJson() + ); + } + + @Override + public String getRelatedRepository() + { + return "core_external_store_relational_postgres_sql_parser"; + } + + public static CompiledExtension extension() + { + return new PostgresSqlParserExtensionCompiled(); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/natives/ParseSqlStatementToJson.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/natives/ParseSqlStatementToJson.java new file mode 100644 index 00000000000..d4197c22106 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/natives/ParseSqlStatementToJson.java @@ -0,0 +1,50 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.compiled.natives; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.eclipse.collections.api.factory.Stacks; +import org.finos.legend.engine.language.sql.grammar.from.SQLGrammarParser; +import org.finos.legend.engine.protocol.sql.metamodel.Statement; +import org.finos.legend.pure.m3.exception.PureExecutionException; +import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNativeFunctionGeneric; + +public class ParseSqlStatementToJson extends AbstractNativeFunctionGeneric +{ + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + public ParseSqlStatementToJson() + { + super( + ParseSqlStatementToJson.class.getCanonicalName() + "." + "parseSqlStatementToJson", + AbstractNativeFunctionGeneric.getMethod(ParseSqlStatementToJson.class, "parseSqlStatementToJson").getParameterTypes(), + "parseSqlStatementToJson_String_1__String_1_" + ); + } + + public static String parseSqlStatementToJson(String sql) throws PureExecutionException + { + try + { + Statement statement = SQLGrammarParser.newInstance().parseStatement(sql); + return OBJECT_MAPPER.writeValueAsString(statement); + } + catch (JsonProcessingException e) + { + throw new PureExecutionException(e, Stacks.mutable.empty()); + } + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension new file mode 100644 index 00000000000..41422a63b4a --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension @@ -0,0 +1 @@ +org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.compiled.PostgresSqlParserExtensionCompiled \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/test/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/TestPostgresSqlParserFunctionsCompiled.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/test/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/TestPostgresSqlParserFunctionsCompiled.java new file mode 100644 index 00000000000..a616fac0057 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser/src/test/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/compiled/TestPostgresSqlParserFunctionsCompiled.java @@ -0,0 +1,26 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.compiled; + +import junit.framework.Test; +import org.finos.legend.pure.runtime.java.compiled.testHelper.PureTestBuilderCompiled; + +public class TestPostgresSqlParserFunctionsCompiled +{ + public static Test suite() + { + return PureTestBuilderCompiled.buildSuite("meta::external::store::relational::postgresSql::parser"); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/pom.xml new file mode 100644 index 00000000000..b9a34a536e0 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/pom.xml @@ -0,0 +1,106 @@ + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSql + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser + jar + Legend Engine - Pure - Runtime - Java Extension - Interpreted - Functions - Relational Store - Postgres SQL - Parser + + + + + org.finos.legend.pure + legend-pure-m4 + + + org.finos.legend.pure + legend-pure-m3-core + + + org.finos.legend.pure + legend-pure-runtime-java-engine-interpreted + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSql-protocol + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSql-grammar + + + org.finos.legend.engine + legend-engine-pure-functions-relationalStore-postgresSql-parser + runtime + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + runtime + + + + + org.eclipse.collections + eclipse-collections-api + + + org.eclipse.collections + eclipse-collections + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + + + junit + junit + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + test + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + test + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-interpreted-functions-json + test + + + + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/PostgresSqlParserExtensionInterpreted.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/PostgresSqlParserExtensionInterpreted.java new file mode 100644 index 00000000000..a801e6ddd48 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/PostgresSqlParserExtensionInterpreted.java @@ -0,0 +1,36 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.interpreted; + +import org.eclipse.collections.impl.factory.Lists; +import org.eclipse.collections.impl.tuple.Tuples; +import org.finos.legend.pure.runtime.java.interpreted.extension.BaseInterpretedExtension; +import org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension; +import org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.interpreted.natives.ParseSqlStatementToJson; + +public class PostgresSqlParserExtensionInterpreted extends BaseInterpretedExtension +{ + public PostgresSqlParserExtensionInterpreted() + { + super(Lists.mutable.with( + Tuples.pair("parseSqlStatementToJson_String_1__String_1_", ParseSqlStatementToJson::new) + )); + } + + public static InterpretedExtension extension() + { + return new PostgresSqlParserExtensionInterpreted(); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/natives/ParseSqlStatementToJson.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/natives/ParseSqlStatementToJson.java new file mode 100644 index 00000000000..dd482b60d28 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/natives/ParseSqlStatementToJson.java @@ -0,0 +1,67 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.interpreted.natives; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.eclipse.collections.api.list.ListIterable; +import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; +import org.finos.legend.engine.language.sql.grammar.from.SQLGrammarParser; +import org.finos.legend.engine.protocol.sql.metamodel.Statement; +import org.finos.legend.pure.m3.compiler.Context; +import org.finos.legend.pure.m3.exception.PureExecutionException; +import org.finos.legend.pure.m3.navigation.Instance; +import org.finos.legend.pure.m3.navigation.M3Properties; +import org.finos.legend.pure.m3.navigation.ProcessorSupport; +import org.finos.legend.pure.m3.navigation.ValueSpecificationBootstrap; +import org.finos.legend.pure.m4.ModelRepository; +import org.finos.legend.pure.m4.coreinstance.CoreInstance; +import org.finos.legend.pure.runtime.java.interpreted.ExecutionSupport; +import org.finos.legend.pure.runtime.java.interpreted.FunctionExecutionInterpreted; +import org.finos.legend.pure.runtime.java.interpreted.VariableContext; +import org.finos.legend.pure.runtime.java.interpreted.natives.InstantiationContext; +import org.finos.legend.pure.runtime.java.interpreted.natives.NativeFunction; +import org.finos.legend.pure.runtime.java.interpreted.profiler.Profiler; + +import java.util.Stack; + +public class ParseSqlStatementToJson extends NativeFunction +{ + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + private final ModelRepository repository; + + public ParseSqlStatementToJson(FunctionExecutionInterpreted functionExecution, ModelRepository modelRepository) + { + this.repository = modelRepository; + } + + @Override + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + { + try + { + String sql = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); + Statement statement = SQLGrammarParser.newInstance().parseStatement(sql); + String result = OBJECT_MAPPER.writeValueAsString(statement); + return ValueSpecificationBootstrap.newStringLiteral(this.repository, result, processorSupport); + } + catch (JsonProcessingException e) + { + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), e, functionExpressionCallStack); + } + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension new file mode 100644 index 00000000000..2a8d183f560 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension @@ -0,0 +1 @@ +org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.interpreted.PostgresSqlParserExtensionInterpreted \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/test/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/TestPostgresSqlParserFunctionsInterpreted.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/test/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/TestPostgresSqlParserFunctionsInterpreted.java new file mode 100644 index 00000000000..465a42d9e32 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser/src/test/java/org/finos/legend/engine/pure/runtime/external/relational/postgresSql/parser/interpreted/TestPostgresSqlParserFunctionsInterpreted.java @@ -0,0 +1,26 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.external.relational.postgresSql.parser.interpreted; + +import junit.framework.Test; +import org.finos.legend.pure.runtime.java.interpreted.testHelper.PureTestBuilderInterpreted; + +public class TestPostgresSqlParserFunctionsInterpreted +{ + public static Test suite() + { + return PureTestBuilderInterpreted.buildSuite("meta::external::store::relational::postgresSql::parser"); + } +} diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/pom.xml similarity index 91% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/pom.xml rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/pom.xml index 65466c5f256..ac5f5c72130 100644 --- a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/pom.xml @@ -18,14 +18,14 @@ org.finos.legend.engine - legend-engine-xts-sql - 4.62.2-SNAPSHOT + legend-engine-xt-relationalStore-postgresSql + 4.65.3-SNAPSHOT 4.0.0 - legend-engine-xt-sql-grammar + legend-engine-xt-relationalStore-postgresSql-grammar jar - Legend Engine - XT - SQL - Grammar + Legend Engine - XT - Relational Store - Postgres SQL - Grammar @@ -71,7 +71,7 @@ org.finos.legend.engine - legend-engine-xt-sql-protocol + legend-engine-xt-relationalStore-postgresSql-protocol diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseLexer.g4 b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseLexer.g4 similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseLexer.g4 rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseLexer.g4 diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseParser.g4 b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseParser.g4 similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseParser.g4 rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/antlr4/org/finos/legend/engine/language/sql/grammar/from/antlr4/SqlBaseParser.g4 diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/AbstractSqlBaseLexer.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/AbstractSqlBaseLexer.java similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/AbstractSqlBaseLexer.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/AbstractSqlBaseLexer.java diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLGrammarParser.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLGrammarParser.java similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLGrammarParser.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLGrammarParser.java diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLParserException.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLParserException.java similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLParserException.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SQLParserException.java diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SqlVisitor.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SqlVisitor.java similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SqlVisitor.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/from/SqlVisitor.java diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/to/SQLGrammarComposer.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/to/SQLGrammarComposer.java similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/to/SQLGrammarComposer.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/main/java/org/finos/legend/engine/language/sql/grammar/to/SQLGrammarComposer.java diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/test/java/org/finos/legend/engine/language/sql/grammar/test/roundtrip/TestSQLRoundTrip.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/test/java/org/finos/legend/engine/language/sql/grammar/test/roundtrip/TestSQLRoundTrip.java similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-grammar/src/test/java/org/finos/legend/engine/language/sql/grammar/test/roundtrip/TestSQLRoundTrip.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-grammar/src/test/java/org/finos/legend/engine/language/sql/grammar/test/roundtrip/TestSQLRoundTrip.java diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-protocol/pom.xml similarity index 95% rename from legend-engine-xts-sql/legend-engine-xt-sql-protocol/pom.xml rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-protocol/pom.xml index fc3bb3910dd..0152aab5193 100644 --- a/legend-engine-xts-sql/legend-engine-xt-sql-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-protocol/pom.xml @@ -18,14 +18,14 @@ org.finos.legend.engine - legend-engine-xts-sql - 4.62.2-SNAPSHOT + legend-engine-xt-relationalStore-postgresSql + 4.65.3-SNAPSHOT 4.0.0 - legend-engine-xt-sql-protocol + legend-engine-xt-relationalStore-postgresSql-protocol jar - Legend Engine - XT - SQL - Protocol + Legend Engine - XT - Relational Store - Postgres SQL - Protocol diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-protocol/src/main/resources/core_external_query_sql_metamodel.protocol.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-protocol/src/main/resources/core_external_query_sql_metamodel.protocol.json similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-protocol/src/main/resources/core_external_query_sql_metamodel.protocol.json rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-protocol/src/main/resources/core_external_query_sql_metamodel.protocol.json diff --git a/legend-engine-xts-sql/legend-engine-xt-sql-protocol/src/main/resources/core_external_query_sql_schema_metamodel.protocol.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-protocol/src/main/resources/core_external_query_sql_schema_metamodel.protocol.json similarity index 100% rename from legend-engine-xts-sql/legend-engine-xt-sql-protocol/src/main/resources/core_external_query_sql_schema_metamodel.protocol.json rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSql-protocol/src/main/resources/core_external_query_sql_schema_metamodel.protocol.json diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/pom.xml similarity index 97% rename from legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/pom.xml rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/pom.xml index 6c381a9dad0..a2d691e42aa 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/pom.xml @@ -18,8 +18,8 @@ org.finos.legend.engine - legend-engine-xt-relationalStore-pure - 4.62.2-SNAPSHOT + legend-engine-xt-relationalStore-postgresSql + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/java/org/finos/legend/engine/code/core/CoreExternalStoreRelationalPostgresSqlModelCodeRepositoryProvider.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/java/org/finos/legend/engine/code/core/CoreExternalStoreRelationalPostgresSqlModelCodeRepositoryProvider.java similarity index 100% rename from legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/java/org/finos/legend/engine/code/core/CoreExternalStoreRelationalPostgresSqlModelCodeRepositoryProvider.java rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/java/org/finos/legend/engine/code/core/CoreExternalStoreRelationalPostgresSqlModelCodeRepositoryProvider.java diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider similarity index 100% rename from legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model.definition.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model.definition.json similarity index 100% rename from legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model.definition.json rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model.definition.json diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/metamodel.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/metamodel.pure similarity index 100% rename from legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/metamodel.pure rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/metamodel.pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/schema_metamodel.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/schema_metamodel.pure similarity index 100% rename from legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/schema_metamodel.pure rename to legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/legend-engine-xt-relationalStore-postgresSqlModel-pure/src/main/resources/core_external_store_relational_postgres_sql_model/schema_metamodel.pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/pom.xml new file mode 100644 index 00000000000..3d1293f8c86 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-postgresSql/pom.xml @@ -0,0 +1,37 @@ + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-generation + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-xt-relationalStore-postgresSql + pom + Legend Engine - XT - Relational Store - Postgres SQL + + + legend-engine-xt-relationalStore-postgresSqlModel-pure + legend-engine-xt-relationalStore-postgresSql-protocol + legend-engine-xt-relationalStore-postgresSql-grammar + legend-engine-pure-functions-relationalStore-postgresSql-parser + legend-engine-pure-runtime-java-extension-compiled-functions-relationalStore-postgresSql-parser + legend-engine-pure-runtime-java-extension-interpreted-functions-relationalStore-postgresSql-parser + + \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/pom.xml index ce69d2d7483..ed782b98be4 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-generation - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/pom.xml new file mode 100644 index 00000000000..bec4c76dea8 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/pom.xml @@ -0,0 +1,245 @@ + + + + + + org.finos.legend.engine + legend-engine-xt-relationalStore-pure + 4.65.3-SNAPSHOT + + 4.0.0 + + legend-engine-xt-relationalStore-SDT-pure + jar + Legend Engine - XT - Relational Store - SDT - PAR/JAVA + + + + + org.finos.legend.pure + legend-pure-maven-generation-par + + src/main/resources + ${legend.pure.version} + + core_external_store_relational_sdt + + + ${project.basedir}/src/main/resources/core_external_store_relational_sdt.definition.json + + + + + generate-sources + + build-pure-jar + + + + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-relationalStore-sqlDialectTranslation-pure + ${project.version} + + + + + org.finos.legend.pure + legend-pure-maven-generation-java + + + compile + + build-pure-compiled-jar + + + true + true + modular + true + + core_external_store_relational_sdt + + + + + + + org.finos.legend.pure + legend-pure-m2-dsl-diagram-grammar + ${legend.pure.version} + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-xt-relationalStore-sqlDialectTranslation-pure + ${project.version} + + + + + maven-surefire-plugin + + false + + **/Test_Postgres_SDT*.java + **/SdtTestSuiteBuilder*.java + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + + + + org.finos.legend.pure + legend-pure-m4 + + + org.finos.legend.pure + legend-pure-m3-core + + + org.finos.legend.pure + legend-pure-runtime-java-engine-compiled + + + org.finos.legend.pure + legend-pure-runtime-java-engine-interpreted + + + org.finos.legend.pure + legend-pure-m2-store-relational-pure + + + org.finos.legend.pure + legend-pure-runtime-java-extension-interpreted-store-relational + + + org.finos.legend.pure + legend-pure-runtime-java-extension-compiled-store-relational + + + + + + org.finos.legend.engine + legend-engine-pure-platform-java + + + org.finos.legend.engine + legend-engine-pure-platform-store-relational-java + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-unclassified + + + org.finos.legend.engine + legend-engine-pure-code-compiled-core + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgresSqlModel-pure + + + org.finos.legend.engine + legend-engine-xt-relationalStore-sqlDialectTranslation-pure + + + org.finos.legend.engine + legend-engine-xt-relationalStore-protocol + + + org.finos.legend.engine + legend-engine-xt-relationalStore-executionPlan + + + org.finos.legend.engine + legend-engine-xt-relationalStore-executionPlan-connection + + + org.finos.legend.engine + legend-engine-xt-relationalStore-executionPlan-connection-authentication-default + + + + + org.eclipse.collections + eclipse-collections + + + org.eclipse.collections + eclipse-collections-api + + + + + junit + junit + + + org.finos.legend.engine + legend-engine-test-framework + test + + + org.finos.legend.engine + legend-engine-xt-relationalStore-postgres-PCT + test + + + + + \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/RunSqlDialectTestQueryHelper.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/RunSqlDialectTestQueryHelper.java new file mode 100644 index 00000000000..2635ae56040 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/RunSqlDialectTestQueryHelper.java @@ -0,0 +1,98 @@ +// Copyright 2024 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. + + +package org.finos.legend.engine.pure.runtime.relational.sdt; + +import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.stack.MutableStack; +import org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider; +import org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProviderConfiguration; +import org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration; +import org.finos.legend.engine.plan.execution.stores.relational.connection.manager.ConnectionManagerSelector; +import org.finos.legend.engine.plan.execution.stores.relational.connection.tests.api.TestConnectionIntegration; +import org.finos.legend.engine.plan.execution.stores.relational.connection.tests.api.TestConnectionIntegrationLoader; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseType; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection; +import org.finos.legend.pure.m3.exception.PureExecutionException; +import org.finos.legend.pure.m4.coreinstance.CoreInstance; + +import javax.security.auth.Subject; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Collections; +import java.util.Optional; + +public class RunSqlDialectTestQueryHelper +{ + private RunSqlDialectTestQueryHelper() + { + + } + + public static T runTestQueryAndTransformResultSet(String dbType, String testQuery, RichIterable setupSqls, RichIterable teardownSqls, Function resultSetTransformFunction, MutableStack functionExpressionCallStack) throws SQLException + { + TestConnectionIntegration found = TestConnectionIntegrationLoader.extensions().select(c -> c.getDatabaseType() == DatabaseType.valueOf(dbType)).getFirst(); + if (found == null) + { + throw new PureExecutionException("Can't find a TestConnectionIntegration for dbType " + dbType + ". Available ones are " + TestConnectionIntegrationLoader.extensions().collect(c -> c.getDatabaseType().name()), functionExpressionCallStack); + } + RelationalDatabaseConnection relationalDatabaseConnection = found.getConnection(); + + Connection connection = null; + Statement statement = null; + try + { + LegendDefaultDatabaseAuthenticationFlowProvider flowProvider = new LegendDefaultDatabaseAuthenticationFlowProvider(); + flowProvider.configure(new LegendDefaultDatabaseAuthenticationFlowProviderConfiguration()); + ConnectionManagerSelector connectionManagerSelector = new ConnectionManagerSelector(new TemporaryTestDbConfiguration(-1), Collections.emptyList(), Optional.of(flowProvider)); + connection = connectionManagerSelector.getDatabaseConnection((Subject) null, relationalDatabaseConnection); + statement = connection.createStatement(); + + for (String s : setupSqls) + { + statement.execute(s); + } + + try (ResultSet resultSet = statement.executeQuery(testQuery)) + { + return resultSetTransformFunction.apply(resultSet); + } + } + finally + { + if (statement != null) + { + for (String s : teardownSqls) + { + try + { + statement.execute(s); + } + catch (Exception e) + { + // Run remaining teardown stmts without failing + System.out.println(e.getMessage()); + } + } + + statement.close(); + connection.close(); + } + } + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/compiled/RunSqlDialectTestQueryCompiledExtension.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/compiled/RunSqlDialectTestQueryCompiledExtension.java new file mode 100644 index 00000000000..ce9ae5d839c --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/compiled/RunSqlDialectTestQueryCompiledExtension.java @@ -0,0 +1,122 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.relational.sdt.compiled; + +import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Stacks; +import org.eclipse.collections.api.list.ListIterable; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.list.mutable.FastList; +import org.finos.legend.engine.pure.runtime.relational.sdt.RunSqlDialectTestQueryHelper; +import org.finos.legend.pure.generated.Root_meta_relational_metamodel_SQLNull_Impl; +import org.finos.legend.pure.generated.Root_meta_relational_metamodel_execute_ResultSet; +import org.finos.legend.pure.generated.Root_meta_relational_metamodel_execute_ResultSet_Impl; +import org.finos.legend.pure.generated.Root_meta_relational_metamodel_execute_Row; +import org.finos.legend.pure.generated.Root_meta_relational_metamodel_execute_Row_Impl; +import org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.SQLNull; +import org.finos.legend.pure.m3.exception.PureExecutionException; +import org.finos.legend.pure.m4.coreinstance.CoreInstance; +import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport; +import org.finos.legend.pure.runtime.java.compiled.extension.BaseCompiledExtension; +import org.finos.legend.pure.runtime.java.compiled.generation.ProcessorContext; +import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNative; +import org.finos.legend.pure.runtime.java.extension.store.relational.compiled.RelationalNativeImplementation; +import org.finos.legend.pure.runtime.java.extension.store.relational.compiled.natives.ResultSetValueHandlers; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.GregorianCalendar; +import java.util.Stack; +import java.util.TimeZone; + +public class RunSqlDialectTestQueryCompiledExtension extends BaseCompiledExtension +{ + public RunSqlDialectTestQueryCompiledExtension() + { + super( + "core_external_store_relational_sdt", + () -> Lists.fixedSize.with(new RunSqlDialectTestQuery()), + Lists.fixedSize.with(), + Lists.fixedSize.empty(), + Lists.fixedSize.empty()); + } + + public static class RunSqlDialectTestQuery extends AbstractNative + { + public RunSqlDialectTestQuery() + { + super("runSqlDialectTestQuery_String_1__String_1__String_MANY__String_MANY__ResultSet_1_"); + } + + @Override + public String build(CoreInstance topLevelElement, CoreInstance functionExpression, ListIterable transformedParams, ProcessorContext processorContext) + { + return "org.finos.legend.engine.pure.runtime.relational.sdt.compiled.RunSqlDialectTestQueryCompiledExtension.RunSqlDialectTestQuery.compileExec(" + + transformedParams.get(0) + ", " + // DB Type + transformedParams.get(1) + ", " + // Test Query + transformedParams.get(2) + ", " + // Setup Sqls + transformedParams.get(3) + ", " + // Teardown Sqls + "(CompiledExecutionSupport) es)"; + } + + public static Root_meta_relational_metamodel_execute_ResultSet compileExec(String dbType, String testQuery, RichIterable setupSqls, RichIterable teardownSqls, CompiledExecutionSupport es) + { + Function transformer = (resultSet) -> + { + try + { + ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); + Root_meta_relational_metamodel_execute_ResultSet pureResult = new Root_meta_relational_metamodel_execute_ResultSet_Impl(""); + SQLNull sqlNull = new Root_meta_relational_metamodel_SQLNull_Impl("SQLNull"); + + int count = resultSetMetaData.getColumnCount(); + MutableList columns = FastList.newList(count); + for (int i = 1; i <= count; i++) + { + String column = resultSetMetaData.getColumnLabel(i); + columns.add(column); + } + pureResult._columnNames(columns); + + ListIterable handlers = ResultSetValueHandlers.getHandlers(resultSetMetaData); + MutableList rows = FastList.newList(); + while (resultSet.next()) + { + MutableList rowValues = RelationalNativeImplementation.processRow(resultSet, handlers, sqlNull, new GregorianCalendar(TimeZone.getTimeZone("UTC"))); + rows.add((new Root_meta_relational_metamodel_execute_Row_Impl(""))._valuesAddAll(rowValues)._parent(pureResult)); + } + pureResult._rows(rows); + return pureResult; + } + catch (SQLException e) + { + throw new PureExecutionException(e, Stacks.mutable.empty()); + } + }; + + try + { + return RunSqlDialectTestQueryHelper.runTestQueryAndTransformResultSet(dbType, testQuery, setupSqls, teardownSqls, transformer, Stacks.mutable.empty()); + } + catch (SQLException e) + { + throw new PureExecutionException(e, Stacks.mutable.empty()); + } + } + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/interpreted/RunSqlDialectTestQueryInterpretedExtension.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/interpreted/RunSqlDialectTestQueryInterpretedExtension.java new file mode 100644 index 00000000000..d05a3c17b10 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/engine/pure/runtime/relational/sdt/interpreted/RunSqlDialectTestQueryInterpretedExtension.java @@ -0,0 +1,97 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.runtime.relational.sdt.interpreted; + +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.list.ListIterable; +import org.eclipse.collections.api.map.MutableMap; +import org.eclipse.collections.api.stack.MutableStack; +import org.eclipse.collections.impl.tuple.Tuples; +import org.finos.legend.engine.pure.runtime.relational.sdt.RunSqlDialectTestQueryHelper; +import org.finos.legend.pure.m3.compiler.Context; +import org.finos.legend.pure.m3.exception.PureExecutionException; +import org.finos.legend.pure.m3.navigation.Instance; +import org.finos.legend.pure.m3.navigation.M3Properties; +import org.finos.legend.pure.m3.navigation.ProcessorSupport; +import org.finos.legend.pure.m3.navigation.ValueSpecificationBootstrap; +import org.finos.legend.pure.m4.ModelRepository; +import org.finos.legend.pure.m4.coreinstance.CoreInstance; +import org.finos.legend.pure.runtime.java.extension.store.relational.interpreted.natives.ExecuteInDb; +import org.finos.legend.pure.runtime.java.interpreted.ExecutionSupport; +import org.finos.legend.pure.runtime.java.interpreted.FunctionExecutionInterpreted; +import org.finos.legend.pure.runtime.java.interpreted.VariableContext; +import org.finos.legend.pure.runtime.java.interpreted.extension.BaseInterpretedExtension; +import org.finos.legend.pure.runtime.java.interpreted.natives.InstantiationContext; +import org.finos.legend.pure.runtime.java.interpreted.natives.NativeFunction; +import org.finos.legend.pure.runtime.java.interpreted.profiler.Profiler; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Stack; + +public class RunSqlDialectTestQueryInterpretedExtension extends BaseInterpretedExtension +{ + public RunSqlDialectTestQueryInterpretedExtension() + { + super(Lists.fixedSize.with( + Tuples.pair("runSqlDialectTestQuery_String_1__String_1__String_MANY__String_MANY__ResultSet_1_", RunSqlDialectTestQuery::new) + )); + } + + public static class RunSqlDialectTestQuery extends NativeFunction + { + private final ModelRepository repository; + + public RunSqlDialectTestQuery(FunctionExecutionInterpreted functionExecution, ModelRepository repository) + { + this.repository = repository; + } + + @Override + public CoreInstance execute(ListIterable params, Stack> resolvedTypeParameters, Stack> resolvedMultiplicityParameters, VariableContext variableContext, MutableStack functionExpressionCallStack, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException + { + String dbType = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); + String testQuery = Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport).getName(); + ListIterable setupSqls = Instance.getValueForMetaPropertyToManyResolved(params.get(2), M3Properties.values, processorSupport).collect(CoreInstance::getName); + ListIterable teardownSqls = Instance.getValueForMetaPropertyToManyResolved(params.get(3), M3Properties.values, processorSupport).collect(CoreInstance::getName); + + Function transformer = (resultSet) -> + { + CoreInstance pureResult = repository.newAnonymousCoreInstance(functionExpressionCallStack.peek().getSourceInformation(), processorSupport.package_getByUserPath("meta::relational::metamodel::execute::ResultSet")); + CoreInstance rowClassifier = processorSupport.package_getByUserPath("meta::relational::metamodel::execute::Row"); + Instance.addValueToProperty(pureResult, "connectionAcquisitionTimeInNanoSecond", this.repository.newIntegerCoreInstance(-1), processorSupport); + try + { + ExecuteInDb.createPureResultSetFromDatabaseResultSet(pureResult, resultSet, functionExpressionCallStack.peek(), rowClassifier, "UTC", repository, System.nanoTime(), 200, processorSupport); + return ValueSpecificationBootstrap.wrapValueSpecification(pureResult, true, processorSupport); + } + catch (SQLException e) + { + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), e, functionExpressionCallStack); + } + }; + + try + { + return RunSqlDialectTestQueryHelper.runTestQueryAndTransformResultSet(dbType, testQuery, setupSqls, teardownSqls, transformer, functionExpressionCallStack); + } + catch (SQLException e) + { + throw new PureExecutionException(functionExpressionCallStack.peek().getSourceInformation(), e, functionExpressionCallStack); + } + } + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/pure/code/core/CoreExternalStoreRelationalSDTCodeRepositoryProvider.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/pure/code/core/CoreExternalStoreRelationalSDTCodeRepositoryProvider.java new file mode 100644 index 00000000000..43de61b8d9e --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/java/org/finos/legend/pure/code/core/CoreExternalStoreRelationalSDTCodeRepositoryProvider.java @@ -0,0 +1,28 @@ +// Copyright 2024 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. + +package org.finos.legend.pure.code.core; + +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepository; +import org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider; +import org.finos.legend.pure.m3.serialization.filesystem.repository.GenericCodeRepository; + +public class CoreExternalStoreRelationalSDTCodeRepositoryProvider implements CodeRepositoryProvider +{ + @Override + public CodeRepository repository() + { + return GenericCodeRepository.build("core_external_store_relational_sdt.definition.json"); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider new file mode 100644 index 00000000000..820cb9c5a7d --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.m3.serialization.filesystem.repository.CodeRepositoryProvider @@ -0,0 +1 @@ +org.finos.legend.pure.code.core.CoreExternalStoreRelationalSDTCodeRepositoryProvider \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension new file mode 100644 index 00000000000..80dbf8bd3fc --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.compiled.extension.CompiledExtension @@ -0,0 +1 @@ +org.finos.legend.engine.pure.runtime.relational.sdt.compiled.RunSqlDialectTestQueryCompiledExtension \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension new file mode 100644 index 00000000000..00470d693b3 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/META-INF/services/org.finos.legend.pure.runtime.java.interpreted.extension.InterpretedExtension @@ -0,0 +1 @@ +org.finos.legend.engine.pure.runtime.relational.sdt.interpreted.RunSqlDialectTestQueryInterpretedExtension \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt.definition.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt.definition.json new file mode 100644 index 00000000000..506802b8793 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt.definition.json @@ -0,0 +1,19 @@ +{ + "name": "core_external_store_relational_sdt", + "pattern": "(meta::external::store::relational::sdt)(::.*)?", + "dependencies": [ + "platform", + "platform_dsl_store", + "platform_dsl_mapping", + "platform_dsl_path", + "platform_dsl_graph", + "platform_dsl_diagram", + "platform_store_relational", + "core_functions_standard", + "core_functions_unclassified", + "core_functions_json", + "core", + "core_external_store_relational_postgres_sql_model", + "core_external_store_relational_sql_dialect_translation" + ] +} \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt/sdtFramework.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt/sdtFramework.pure new file mode 100644 index 00000000000..75a0898a3dc --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt/sdtFramework.pure @@ -0,0 +1,131 @@ +// Copyright 2024 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 meta::external::query::sql::metamodel::*; +import meta::external::store::relational::sqlDialectTranslation::*; +import meta::external::store::relational::sdt::framework::*; +import meta::pure::extension::*; +import meta::pure::functions::meta::*; +import meta::json::*; + +// SDT - SQL Dialect Test + +native function meta::external::store::relational::sdt::framework::runSqlDialectTestQuery(dbType: String[1], testQuery: String[1], setupSqls: String[*], teardownSqls: String[*]): meta::relational::metamodel::execute::ResultSet[1]; + +function meta::external::store::relational::sdt::framework::runSqlDialect(sdt: SqlDialectTest[1], dbType: String[1], extensions: Extension[*]): Boolean[1] +{ + let testQuery = $sdt->generateTestSqlForSdtTestCase($dbType, $extensions); + let setupSqls = $sdt->generateSetupSqlsForSdtTestCase($dbType, $extensions); + let teardownSqls = $sdt->generateTeardownSqlsForSdtTestCase($dbType, $extensions); + let result = $dbType->runSqlDialectTestQuery($testQuery, $setupSqls, $teardownSqls)->testResultFromResultSet(); + $sdt->assertSdtTestPasses($result); +} + +Profile meta::external::store::relational::sdt::framework::SDT +{ + stereotypes : [test]; +} + +Class meta::external::store::relational::sdt::framework::SqlDialectTest +{ + setupStatements: Statement[*]; + teardownStatements: Statement[*]; + testQuery: Query[1]; + expectedResult: TestResult[1]; +} + +Class meta::external::store::relational::sdt::framework::TestResult +{ + <> columnNames: String[*]; + <> rows: TestResultRow[*]; +} + +Class meta::external::store::relational::sdt::framework::TestResultRow +{ + <> values: Any[*]; +} + +function meta::external::store::relational::sdt::framework::collectSDTTestsInPackage(pkg: String[1]): ConcreteFunctionDefinition<{->SqlDialectTest[1]}>[*] +{ + getAllPackageElements($pkg->pathToElement()->cast(@Package), true) + ->filter(x | $x->hasStereotype('test', SDT)) + ->map(x | $x->match([ + f: ConcreteFunctionDefinition<{->SqlDialectTest[1]}>[1] | $f, + a: Any[*] | $x->elementToPath() + ' element with stereotype SDT.test not a concrete function definition returning SqlDialectTest[1]'; []; + ])); +} + +function meta::external::store::relational::sdt::framework::getSqlDialectTest(func: ConcreteFunctionDefinition<{->SqlDialectTest[1]}>[1]): SqlDialectTest[1] +{ + $func->eval() +} + +function <> meta::external::store::relational::sdt::framework::generateSetupSqlsForSdtTestCase(sdt: SqlDialectTest[1], dbType: String[1], extensions: Extension[*]): String[*] +{ + $sdt.setupStatements->map(s | $s->generateSqlDialectForStatement(sdtTestSqlDialectTranslationConfig($dbType), $extensions)) +} + +function <> meta::external::store::relational::sdt::framework::generateTestSqlForSdtTestCase(sdt: SqlDialectTest[1], dbType: String[1], extensions: Extension[*]): String[1] +{ + $sdt.testQuery->generateSqlDialectForStatement(sdtTestSqlDialectTranslationConfig($dbType), $extensions); +} + +function <> meta::external::store::relational::sdt::framework::generateTeardownSqlsForSdtTestCase(sdt: SqlDialectTest[1], dbType: String[1], extensions: Extension[*]): String[*] +{ + $sdt.teardownStatements->map(s | $s->generateSqlDialectForStatement(sdtTestSqlDialectTranslationConfig($dbType), $extensions)) +} + +function <> meta::external::store::relational::sdt::framework::testResultFromResultSet(rs: meta::relational::metamodel::execute::ResultSet[1]): TestResult[1] +{ + ^TestResult + ( + columnNames = $rs.columnNames, + rows = $rs.rows->map(r | ^TestResultRow(values = $r.values)) + ) +} + +function <> meta::external::store::relational::sdt::framework::assertSdtTestPasses(sdt: SqlDialectTest[1], actualResult: TestResult[1]): Boolean[1] +{ + assertEquals($sdt.expectedResult, $actualResult, | 'Expected - ' + $sdt.expectedResult->toJSON(100) + '\n' + 'Actual - ' + $actualResult->toJSON(100)); +} + +function meta::external::store::relational::sdt::framework::testConfigForSimpleExpression(expression: meta::external::query::sql::metamodel::Expression[1], expected: Any[1]): SqlDialectTest[1] +{ + ^SqlDialectTest( + testQuery = ^Query( + queryBody = ^QuerySpecification( + select = ^Select( + distinct = false, + selectItems = ^SingleColumn( + expression = $expression, + alias = 'result' + ) + ) + ) + ), + expectedResult = ^TestResult( + columnNames = ['result'], + rows = [^TestResultRow(values = $expected)] + ) + ) +} + +function <> meta::external::store::relational::sdt::framework::sdtTestSqlDialectTranslationConfig(dbType: String[1]): SqlDialectTranslationConfig[1] +{ + ^SqlDialectTranslationConfig + ( + dbConfig = ^DbConfig(dbType = $dbType), + formatConfig = ^FormatConfig(pretty = false, upperCaseKeywords = true) + ) +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt/sdtSuite/numberArithmeticSdtSuite.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt/sdtSuite/numberArithmeticSdtSuite.pure new file mode 100644 index 00000000000..c3bf8b760d1 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/main/resources/core_external_store_relational_sdt/sdtSuite/numberArithmeticSdtSuite.pure @@ -0,0 +1,87 @@ +// Copyright 2024 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 meta::external::query::sql::metamodel::*; +import meta::external::store::relational::sdt::framework::*; + +function <> meta::external::store::relational::sdt::suite::numberArithmetic::add(): SqlDialectTest[1] +{ + testConfigForSimpleExpression( + ^ArithmeticExpression(left = ^IntegerLiteral(value = 101), right = ^IntegerLiteral(value = 202), type = ArithmeticType.ADD), + 303 + ) +} + +function <> meta::external::store::relational::sdt::suite::numberArithmetic::subtract(): SqlDialectTest[1] +{ + testConfigForSimpleExpression( + ^ArithmeticExpression(left = ^IntegerLiteral(value = 101), right = ^IntegerLiteral(value = 202), type = ArithmeticType.SUBTRACT), + -101 + ) +} + +function <> meta::external::store::relational::sdt::suite::numberArithmetic::multiply(): SqlDialectTest[1] +{ + testConfigForSimpleExpression( + ^ArithmeticExpression(left = ^IntegerLiteral(value = 101), right = ^IntegerLiteral(value = 202), type = ArithmeticType.MULTIPLY), + 20402 + ) +} + +function <> meta::external::store::relational::sdt::suite::numberArithmetic::divide(): SqlDialectTest[1] +{ + testConfigForSimpleExpression( + ^ArithmeticExpression(left = ^IntegerLiteral(value = 101), right = ^IntegerLiteral(value = 202), type = ArithmeticType.DIVIDE), + 0.5 + ) +} + +function <> meta::external::store::relational::sdt::suite::numberArithmetic::divideComplexCase1(): SqlDialectTest[1] +{ + // 101 / (202 * 1.0) => 0.5 + testConfigForSimpleExpression( + ^ArithmeticExpression( + left = ^IntegerLiteral(value = 101), + right = ^ArithmeticExpression(left = ^IntegerLiteral(value = 202), right = ^DoubleLiteral(value = 1.0), type = ArithmeticType.MULTIPLY), + type = ArithmeticType.DIVIDE + ), + 0.5 + ) +} + +function <> meta::external::store::relational::sdt::suite::numberArithmetic::precedence1(): SqlDialectTest[1] +{ + // (2 * 3) + 4 => 10 + testConfigForSimpleExpression( + ^ArithmeticExpression( + left = ^ArithmeticExpression(left = ^IntegerLiteral(value = 2), right = ^IntegerLiteral(value = 3), type = ArithmeticType.MULTIPLY), + right = ^IntegerLiteral(value = 4), + type = ArithmeticType.ADD + ), + 10 + ) +} + +function <> meta::external::store::relational::sdt::suite::numberArithmetic::precedence2(): SqlDialectTest[1] +{ + // 2 * (3 + 4) => 14 + testConfigForSimpleExpression( + ^ArithmeticExpression( + left = ^IntegerLiteral(value = 2), + right = ^ArithmeticExpression(left = ^IntegerLiteral(value = 3), right = ^IntegerLiteral(value = 4), type = ArithmeticType.ADD), + type = ArithmeticType.MULTIPLY + ), + 14 + ) +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/pure/code/core/Test_Pure_ExternalStoreRelationalSDT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/pure/code/core/Test_Pure_ExternalStoreRelationalSDT.java new file mode 100644 index 00000000000..c405e76a06c --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/pure/code/core/Test_Pure_ExternalStoreRelationalSDT.java @@ -0,0 +1,32 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.pure.code.core; + +import junit.framework.TestSuite; +import org.finos.legend.pure.m3.execution.test.PureTestBuilder; +import org.finos.legend.pure.runtime.java.compiled.testHelper.PureTestBuilderCompiled; +import org.finos.legend.pure.m3.execution.test.TestCollection; +import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport; + +public class Test_Pure_ExternalStoreRelationalSDT +{ + public static TestSuite suite() + { + CompiledExecutionSupport executionSupport = PureTestBuilderCompiled.getClassLoaderExecutionSupport(); + TestSuite suite = new TestSuite(); + suite.addTest(PureTestBuilderCompiled.buildSuite(TestCollection.collectTests("meta::external::store::relational::sdt", executionSupport.getProcessorSupport(), fn -> PureTestBuilderCompiled.generatePureTestCollection(fn, executionSupport), ci -> PureTestBuilder.satisfiesConditions(ci, executionSupport.getProcessorSupport())), executionSupport)); + return suite; + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/relational/test/sdt/SdtTestSuiteBuilder.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/relational/test/sdt/SdtTestSuiteBuilder.java new file mode 100644 index 00000000000..f752ded415e --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/relational/test/sdt/SdtTestSuiteBuilder.java @@ -0,0 +1,119 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.relational.test.sdt; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import org.eclipse.collections.api.RichIterable; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Sets; +import org.finos.legend.engine.plan.execution.stores.relational.connection.tests.api.TestConnectionIntegrationLoader; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseType; +import org.finos.legend.engine.test.shared.framework.TestServerResource; +import org.finos.legend.pure.generated.*; +import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition; +import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport; +import org.junit.Assert; + +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +import static org.finos.legend.engine.test.shared.framework.PureTestHelperFramework.getClassLoaderExecutionSupport; +import static org.finos.legend.engine.test.shared.framework.PureTestHelperFramework.wrapSuite; +import static org.finos.legend.pure.generated.core_external_store_relational_sdt_sdtFramework.*; +import static org.finos.legend.pure.generated.platform_pure_essential_meta_graph_elementToPath.*; + +public class SdtTestSuiteBuilder +{ + private static final Set SDT_TEST_PACKAGES = Sets.fixedSize.of( + "meta::external::store::relational::sdt::suite" + ); + + public static Test buildSdtTestSuite(String dbType, Function> extensionsFunc, Map expectedErrors) + { + final CompiledExecutionSupport es = getClassLoaderExecutionSupport(); + RichIterable extensions = extensionsFunc.apply(es); + TestSuite suite = new TestSuite(); + SDT_TEST_PACKAGES.forEach(pkg -> + { + RichIterable> sdtTestInPackage = Root_meta_external_store_relational_sdt_framework_collectSDTTestsInPackage_String_1__ConcreteFunctionDefinition_MANY_(pkg, es); + sdtTestInPackage.forEach(x -> suite.addTest(new SDTTestCase(x, dbType, extensions, es, null))); + }); + return wrapSuite( + () -> true, + () -> suite, + () -> false, + Lists.mutable.with((TestServerResource) TestConnectionIntegrationLoader.extensions().select(c -> c.getDatabaseType() == DatabaseType.valueOf(dbType)).getFirst()) + ); + } + + public static final class SDTTestCase extends TestCase + { + ConcreteFunctionDefinition func; + String dbType; + RichIterable extensions; + CompiledExecutionSupport es; + String expectedError; + + public SDTTestCase() + { + } + + public SDTTestCase(ConcreteFunctionDefinition func, String dbType, RichIterable extensions, CompiledExecutionSupport es, String expectedError) + { + super(Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_(func, es)); + this.dbType = dbType; + this.extensions = extensions; + this.func = func; + this.es = es; + this.expectedError = expectedError; + } + + @Override + protected void runTest() throws Throwable + { + System.out.print("EXECUTING " + this.getName() + " ... "); + long start = System.nanoTime(); + + boolean testPass = false; + try + { + Root_meta_external_store_relational_sdt_framework_runSqlDialect_SqlDialectTest_1__String_1__Extension_MANY__Boolean_1_( + Root_meta_external_store_relational_sdt_framework_getSqlDialectTest_ConcreteFunctionDefinition_1__SqlDialectTest_1_(this.func, this.es), + this.dbType, + this.extensions, + this.es + ); + testPass = true; + } + catch (Exception e) + { + if (expectedError != null) + { + Assert.assertEquals(expectedError, e.getMessage()); + testPass = true; + return; + } + throw e; + } + finally + { + System.out.format("%s (%.6fs)\n", (testPass ? "DONE" : "FAIL"), (System.nanoTime() - start) / 1_000_000_000.0); + } + } + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/relational/test/sdt/postgres/Test_Postgres_SDT.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/relational/test/sdt/postgres/Test_Postgres_SDT.java new file mode 100644 index 00000000000..a498466e0f9 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-SDT-pure/src/test/java/org/finos/legend/engine/relational/test/sdt/postgres/Test_Postgres_SDT.java @@ -0,0 +1,35 @@ +// Copyright 2024 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. + +package org.finos.legend.engine.relational.test.sdt.postgres; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.Maps; +import org.finos.legend.engine.relational.test.sdt.SdtTestSuiteBuilder; + +import static org.finos.legend.pure.generated.core_external_store_relational_sql_dialect_translation_postgres_postgresSqlDialect.*; + +public class Test_Postgres_SDT extends TestSuite +{ + public static Test suite() + { + return SdtTestSuiteBuilder.buildSdtTestSuite( + "Postgres", + es -> Lists.immutable.of(Root_meta_external_store_relational_sqlDialectTranslation_postgres_postgresSqlDialectExtension__Extension_1_(es)), + Maps.mutable.empty() + ); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/pom.xml index dd7bdded6b4..e3e511691e9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -431,6 +431,21 @@ legend-engine-language-pure-compiler test + + org.finos.legend.engine + legend-engine-pure-functions-planExecution-pure + test + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-planExecution + test + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-shared-functions-planExecution + test + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/lineage/scanRelations/scanRelations.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/lineage/scanRelations/scanRelations.pure index bf5130318e4..31dd40ebd57 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/lineage/scanRelations/scanRelations.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/lineage/scanRelations/scanRelations.pure @@ -691,14 +691,16 @@ function <> meta::pure::lineage::scanRelations::isNull(d:DynaFun function <> meta::pure::lineage::scanRelations::extractSourceColumn(tableAliasColumn:TableAliasColumn[1], sourceOperation:RelationalOperationElement[1], relationIdentifiers:String[*], sourceTree:RelationTree[1]):Column[*] { $sourceOperation->match([ - v:ViewSelectSQLQuery[1]| if(getRelationName($v.view)->in($relationIdentifiers), |$tableAliasColumn.column, |[]), - t:Table[1] | if(getRelationName($t)->in($relationIdentifiers), |$tableAliasColumn.column, |[]);, - // v:View[1] | if(getRelationName($v)->in($relationIdentifiers), |$tableAliasColumn.column, |[]), // Need not handle views in generated SQL query (as they should have been converted to subqueries) - ta:TableAlias[1] | if($tableAliasColumn.alias.name == $ta.name,| $tableAliasColumn->extractSourceColumn($ta.relation, $relationIdentifiers, $sourceTree), | []);, - s:SelectSQLQuery[1] | $s->extractSourceColumnFromSelectSQLQuery($tableAliasColumn, $relationIdentifiers, $sourceTree);, - u:Union[1] | let colNames = $u.queries->map(query | $query->extractSourceColumnFromSelectSQLQuery($tableAliasColumn, $relationIdentifiers, $sourceTree))->removeDuplicates()->filter(c | $c.name->in($sourceTree.columns.name) && $c.owner->in($sourceTree.columns.owner)); - assert($colNames->size() <=1 ,|'Expected max 1 column a union . Found : ' + $colNames->size()->toString()+ ' in ' +$u.setImplementations.id->joinStrings() ); - if($colNames->isEmpty(), | [], | $colNames->toOne()); + v:ViewSelectSQLQuery[1] | if(getRelationName($v.view)->in($relationIdentifiers), |$tableAliasColumn.column, |[]), + t:Table[1] | if(getRelationName($t)->in($relationIdentifiers), |$tableAliasColumn.column, |[]);, + // v:View[1] | if(getRelationName($v)->in($relationIdentifiers), |$tableAliasColumn.column, |[]), // Need not handle views in generated SQL query (as they should have been converted to subqueries) + ta:TableAlias[1] | if($tableAliasColumn.alias.name == $ta.name,| $tableAliasColumn->extractSourceColumn($ta.relation, $relationIdentifiers, $sourceTree), | []);, + s:SelectSQLQuery[1] | $s->extractSourceColumnFromSelectSQLQuery($tableAliasColumn, $relationIdentifiers, $sourceTree);, + u:Union[1] | let colNames = $u.queries->map(query | $query->extractSourceColumnFromSelectSQLQuery($tableAliasColumn, $relationIdentifiers, $sourceTree))->removeDuplicates()->filter(c | $c.name->in($sourceTree.columns.name) && $c.owner->in($sourceTree.columns.owner)); + assert($colNames->size() <=1 ,|'Expected max 1 column a union . Found : ' + $colNames->size()->toString()+ ' in ' +$u.setImplementations.id->joinStrings() ); + if($colNames->isEmpty(), | [], | $colNames->toOne());, + s:SemiStructuredArrayFlatten[1] | let tac = $s->extractTableAliasColumns(); + if($tac->isEmpty(), | [], | $tac->toOne()->extractSourceColumn($tac.alias.relation->toOne(), $relationIdentifiers, $sourceTree)); ]); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/modelJoins.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/modelJoins.pure index 129e7ae859d..863c12b2f7a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/modelJoins.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/modelJoins.pure @@ -67,12 +67,22 @@ function <> meta::external::store::relational::modelJoins::getCl $classMappings->filter(c| $c.id == $id)->toOne('More than one class mapping at the given id: ' + $id); } -function <> meta::external::store::relational::modelJoins::getAttributeRelationalOperationElement(propertyImplementations:SimpleFunctionExpression[*], thisOrThat:String[1], id:String[1], classMappings:RootRelationalInstanceSetImplementation[*]):RelationalOperationElement[1] +function <> meta::external::store::relational::modelJoins::convertToRelationalElement(vs:ValueSpecification[1], sourceSet:RootRelationalInstanceSetImplementation[1], targetSet: RootRelationalInstanceSetImplementation[1]):RelationalOperationElement[1] { - let propertyImplementation = $propertyImplementations->filter(p|$p.parametersValues->cast(@VariableExpression).name->toOne()==$thisOrThat).func->toOne(); - let classMapping = $classMappings->getClassMappingAtId($id); - let relationalPropertyMapping = $classMapping.propertyMappings->filter(p|$p.property==$propertyImplementation)->cast(@RelationalPropertyMapping)->toOne(); - $relationalPropertyMapping.relationalOperationElement->toOne('Localized relational model joins cannot support more than one relational operation element per property mapping. Found on class mapping id: ' + $id); + $vs->match([ + p : SimpleFunctionExpression[1] | + assert($p.func->instanceOf(Property),|'Expected only property function calls in model joins.'); + let var = $p.parametersValues->evaluateAndDeactivate()->at(0); + assert($var->instanceOf(VariableExpression) && $var->cast(@VariableExpression).name->in(['this','that']),|'Properties of $this or $that can be accessed in model joins.'); + let classMapping = if($var->cast(@VariableExpression).name == 'this', | $sourceSet, | $targetSet); + let relationalPropertyMapping = $classMapping.propertyMappings->filter(x|$x.property==$p.func)->cast(@RelationalPropertyMapping)->toOne(); + $relationalPropertyMapping.relationalOperationElement->toOne('Localized relational model joins cannot support more than one relational operation element per property mapping. Found on class mapping id: ' + $classMapping.id);, + + v : InstanceValue[1] | + assert($v.values->size() == 1 && ($v.values->toOne()->instanceOf(String) || $v.values->toOne()->instanceOf(Number) || $v.values->toOne()->instanceOf(Date)),|'The join key should only have one mapping.'); + ^Literal(value=$v.values->toOne()); + ]); + } function <> meta::external::store::relational::modelJoins::transformExpressionSequenceIntoJoin(expressionSequence: SimpleFunctionExpression[1], sourceId:String[1], targetId:String[1], classMappings:RootRelationalInstanceSetImplementation[*]): Join[1] @@ -85,16 +95,15 @@ function <> meta::external::store::relational::modelJoins::trans let targetDatabase = $targetMainTableAlias.database->toOne(); let aggregatedDatabase = ^Database(includes=[$sourceDatabase, $targetDatabase]); - assertContains(['equal', 'not', 'and', 'or'], $functionOperator, 'Failed to translate XStore Property into Relational Property because function operator is not in standard list'); + assertContains(['equal', 'not', 'and', 'or', 'greaterThanEqual', 'greaterThan', 'lessThanEqual', 'lessThan' ], $functionOperator, 'Failed to translate XStore Property into Relational Property because function operator is not in standard list'); let join = if( - $functionOperator=='equal' || $functionOperator=='not', - | let propertyImplementations = $expressionSequence.parametersValues->cast(@SimpleFunctionExpression)->evaluateAndDeactivate(); + $functionOperator->in(['equal', 'greaterThanEqual', 'greaterThan', 'lessThanEqual', 'lessThan' ]), + | let expressionParameters = $expressionSequence.parametersValues->evaluateAndDeactivate(); + let sourceSet = getClassMappingAtId($classMappings, $sourceId); + let targetSet = getClassMappingAtId($classMappings, $targetId); - let sourceRelationalOperationElement = getAttributeRelationalOperationElement($propertyImplementations, 'this', $sourceId, $classMappings); - let targetRelationalOperationElement = getAttributeRelationalOperationElement($propertyImplementations, 'that', $targetId, $classMappings); - - let parameters = $sourceRelationalOperationElement->concatenate($targetRelationalOperationElement); + let parameters = $expressionParameters->map(e | $e->convertToRelationalElement($sourceSet, $targetSet)); let operation = ^DynaFunction(name=$functionOperator, parameters=$parameters); ^Join( name=$joinName, @@ -117,4 +126,3 @@ function <> meta::external::store::relational::modelJoins::trans ); } - diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/testModelJoinsToRelationalJoins.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/testModelJoinsToRelationalJoins.pure index 9d3f070a4a1..1cc88459d43 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/testModelJoinsToRelationalJoins.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/modelJoins/testModelJoinsToRelationalJoins.pure @@ -13,19 +13,19 @@ import meta::pure::alloy::connections::alloy::specification::*; function <> meta::external::store::relational::modelJoins::test::setUp():Boolean[1] { - let connection = meta::external::store::relational::tests::testRuntime(LocalTradesDatabase).connectionStores.connection->toOne()->cast(@DatabaseConnection); + let connection = meta::external::store::relational::tests::testRuntime(LocalTradesDatabase).connectionStores.connection->toOne()->cast(@meta::external::store::relational::runtime::DatabaseConnection); executeInDb('Drop table if exists LegalEntity;', $connection); - executeInDb('Create Table LegalEntity (ENTITY_ID INT, name VARCHAR(32));', $connection); - executeInDb('insert into LegalEntity (ENTITY_ID, name) values (1, \'Firm X\');', $connection); - executeInDb('insert into LegalEntity (ENTITY_ID, name) values (2, \'Firm A\');', $connection); + executeInDb('Create Table LegalEntity (ENTITY_ID INT, name VARCHAR(32), value INT);', $connection); + executeInDb('insert into LegalEntity (ENTITY_ID, name, value) values (1, \'Firm X\', 12);', $connection); + executeInDb('insert into LegalEntity (ENTITY_ID, name, value) values (2, \'Firm A\', 13);', $connection); executeInDb('Drop table if exists Trade;', $connection); - executeInDb('Create Table Trade(id INT, ENTITY_NAME_FK VARCHAR(32), value INT, ENTITY_ID_FK INT);', $connection); - executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK) values (1, \'Firm X\', 8, 1);', $connection); - executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK) values (2, \'Firm A\', 9, 2);', $connection); - executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK) values (3, \'Firm X\', 10, 1);', $connection); - executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK) values (4, \'Firm X\', 11, 1);', $connection); + executeInDb('Create Table Trade(id INT, ENTITY_NAME_FK VARCHAR(32), value INT, ENTITY_ID_FK INT, date DATE);', $connection); + executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK, date) values (1, \'Firm X\', 8, 1, \'2022-01-01\');', $connection); + executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK, date) values (2, \'Firm A\', 9, 2, \'2023-01-01\');', $connection); + executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK, date) values (3, \'Firm X\', 10, 1, \'2024-01-01\');', $connection); + executeInDb('insert into Trade (id, ENTITY_NAME_FK, value, ENTITY_ID_FK, date) values (4, \'Firm X\', 11, 1, \'2025-01-01\');', $connection); true; } @@ -69,6 +69,38 @@ function <> meta::external::store::relational::modelJoins::test::test ); } + +function <> meta::external::store::relational::modelJoins::test::testJoinWithConstantDouble():Boolean[1] +{ + let query = {|Trade.all()->project([x|$x.value,x|$x.client.name],['Value','Client/Name']);}; + let xstoreResult = executionPlan($query, XStoreTradesMapping_withConstantDouble, getXStoreRuntime(),meta::relational::extension::relationalExtensions()); + assertEquals('select "root".value as "Value", "legalentity_view_0".name as "Client/Name" from Trades.Trade as "root" left outer join (select "root".ENTITY_ID as ENTITY_ID, "root".name as name, "root".value as value from Entity.LegalEntity as "root" group by "root".ENTITY_ID) as "legalentity_view_0" on ("root".ENTITY_ID_FK = "legalentity_view_0".ENTITY_ID and "root".value = 1 and (2 <> "root".value OR "root".value is null) and 1 = 1)', + $xstoreResult.rootExecutionNode.executionNodes->at(0)->cast(@SQLExecutionNode).sqlQuery); +} + +function <> meta::external::store::relational::modelJoins::test::testJoinWithConstantString():Boolean[1] +{ + let query = {|Trade.all()->project([x|$x.value,x|$x.client.name],['Value','Client/Name']);}; + let xstoreResult = executionPlan($query, XStoreTradesMapping_withConstantString, getXStoreRuntime(),meta::relational::extension::relationalExtensions()); + assertEquals('select "root".value as "Value", "legalentity_view_0".name as "Client/Name" from Trades.Trade as "root" left outer join (select "root".ENTITY_ID as ENTITY_ID, "root".name as name, "root".value as value from Entity.LegalEntity as "root" group by "root".ENTITY_ID) as "legalentity_view_0" on ("root".ENTITY_ID_FK = "legalentity_view_0".ENTITY_ID and "root".ENTITY_ID_FK = \'foo\' and (\'bar\' <> "root".ENTITY_ID_FK OR "root".ENTITY_ID_FK is null))', $xstoreResult.rootExecutionNode.executionNodes->at(0)->cast(@SQLExecutionNode).sqlQuery); +} + +function <> meta::external::store::relational::modelJoins::test::testJoinWithConstantDate():Boolean[1] +{ + let query = {|Trade.all()->project([x|$x.value,x|$x.client.name],['Value','Client/Name']);}; + let xstoreResult = executionPlan($query, XStoreTradesMapping_withConstantDate, getXStoreRuntime(),meta::relational::extension::relationalExtensions()); + assertEquals('select "root".value as "Value", "legalentity_view_0".name as "Client/Name" from Trades.Trade as "root" left outer join (select "root".ENTITY_ID as ENTITY_ID, "root".name as name, "root".value as value from Entity.LegalEntity as "root" group by "root".ENTITY_ID) as "legalentity_view_0" on ("root".ENTITY_ID_FK = "legalentity_view_0".ENTITY_ID and "root".date = DATE\'2024-01-01\' and (DATE\'2024-01-01\' <> "root".date OR "root".date is null))', + $xstoreResult.rootExecutionNode.executionNodes->at(0)->cast(@SQLExecutionNode).sqlQuery); +} + +function <> meta::external::store::relational::modelJoins::test::testJoinWithInequalities():Boolean[1] +{ + let query = {|Trade.all()->project([x|$x.value,x|$x.client.name],['Value','Client/Name']);}; + let xstoreResult = executionPlan($query, XStoreTradesMapping_withInequalities, getXStoreRuntime(),meta::relational::extension::relationalExtensions()); + assertEquals('select "root".value as "Value", "legalentity_view_0".name as "Client/Name" from Trades.Trade as "root" left outer join (select "root".ENTITY_ID as ENTITY_ID, "root".name as name, "root".value as value from Entity.LegalEntity as "root" group by "root".ENTITY_ID) as "legalentity_view_0" on ("root".value >= "legalentity_view_0".value and "root".value > "legalentity_view_0".value and "root".value <= "legalentity_view_0".value and "root".value < "legalentity_view_0".value)', + $xstoreResult.rootExecutionNode.executionNodes->at(0)->cast(@SQLExecutionNode).sqlQuery); +} + function <> meta::external::store::relational::modelJoins::test::testPersonToFirmUsingFromProject():Boolean[1] { let xstoreResult = executionPlan({|Trade.all()->from(XStoreTradesMapping, getXStoreRuntime())->project([x|$x.value,x|$x.client.name],['Value','Client/Name']);}, meta::relational::extension::relationalExtensions()); @@ -115,12 +147,14 @@ Class meta::external::store::relational::modelJoins::test::LegalEntity { entityId: String[1]; name: String[1]; + value: Integer[1]; } Class meta::external::store::relational::modelJoins::test::Trade { id: String[1]; value: Integer[1]; + date: Date[1]; } Class meta::external::store::relational::modelJoins::test::OtherEntity @@ -149,14 +183,16 @@ Database meta::external::store::relational::modelJoins::test::EntityDatabase Table LegalEntity ( ENTITY_ID VARCHAR(32) PRIMARY KEY, - name VARCHAR(32) NOT NULL + name VARCHAR(32) NOT NULL, + value INT NOT NULL ) View LegalEntity_View ( ~groupBy (Entity.LegalEntity.ENTITY_ID) ENTITY_ID: Entity.LegalEntity.ENTITY_ID, - name: Entity.LegalEntity.name + name: Entity.LegalEntity.name, + value: Entity.LegalEntity.value ) ) ) @@ -192,7 +228,8 @@ Database meta::external::store::relational::modelJoins::test::XStoreTradesDataba id VARCHAR(32) PRIMARY KEY, value INTEGER NOT NULL, ENTITY_ID_FK VARCHAR(32) NOT NULL, - ENTITY_NAME_FK VARCHAR(32) NOT NULL + ENTITY_NAME_FK VARCHAR(32) NOT NULL, + date DATE NOT NULL ) ) ) @@ -211,7 +248,8 @@ Mapping meta::external::store::relational::modelJoins::test::LegalEntityMapping ) ~mainTable [meta::external::store::relational::modelJoins::test::EntityDatabase]Entity.LegalEntity_View entityId: [meta::external::store::relational::modelJoins::test::EntityDatabase]Entity.LegalEntity_View.ENTITY_ID, - name: [meta::external::store::relational::modelJoins::test::EntityDatabase]Entity.LegalEntity_View.name + name: [meta::external::store::relational::modelJoins::test::EntityDatabase]Entity.LegalEntity_View.name, + value : [meta::external::store::relational::modelJoins::test::EntityDatabase]Entity.LegalEntity_View.value } ) @@ -274,3 +312,68 @@ Mapping meta::external::store::relational::modelJoins::test::XStoreTradesMapping $that.entityIdFk && $this.name == $that.entityNameFk } ) + +Mapping meta::external::store::relational::modelJoins::test::TradesMapping +( + Trade[trade]: Relational + { + ~primaryKey + ( + [XStoreTradesDatabase]Trades.Trade.id + ) + ~mainTable [XStoreTradesDatabase]Trades.Trade + id: [XStoreTradesDatabase]Trades.Trade.id, + value: [XStoreTradesDatabase]Trades.Trade.value, + date: [XStoreTradesDatabase]Trades.Trade.date, + +entityIdFk: String[1]: [XStoreTradesDatabase]Trades.Trade.ENTITY_ID_FK, + +entityNameFk: String[1]: [XStoreTradesDatabase]Trades.Trade.ENTITY_NAME_FK + } +) + +Mapping meta::external::store::relational::modelJoins::test::XStoreTradesMapping_withConstantDouble +( + include meta::external::store::relational::modelJoins::test::LegalEntityMapping + include meta::external::store::relational::modelJoins::test::TradesMapping + + meta::external::store::relational::modelJoins::test::Trade_LegalEntity: XStore + { + client[trade, legal_entity]: $this.entityIdFk == $that.entityId && $this.value == 1 && 2 != $this.value && 1 == 1, + trades[legal_entity, trade]: $this.entityId == $that.entityIdFk && $that.value == 1 && 2 != $that.value && 1 == 1 + } +) + +Mapping meta::external::store::relational::modelJoins::test::XStoreTradesMapping_withConstantString +( + include meta::external::store::relational::modelJoins::test::LegalEntityMapping + include meta::external::store::relational::modelJoins::test::TradesMapping + + meta::external::store::relational::modelJoins::test::Trade_LegalEntity: XStore + { + client[trade, legal_entity]: $this.entityIdFk == $that.entityId && $this.entityIdFk == 'foo' && 'bar' != $this.entityIdFk, + trades[legal_entity, trade]: $this.entityId == $that.entityIdFk && $that.entityIdFk == 'foo' && 'bar' != $that.entityIdFk + } +) + +Mapping meta::external::store::relational::modelJoins::test::XStoreTradesMapping_withConstantDate +( + include meta::external::store::relational::modelJoins::test::LegalEntityMapping + include meta::external::store::relational::modelJoins::test::TradesMapping + + meta::external::store::relational::modelJoins::test::Trade_LegalEntity: XStore + { + client[trade, legal_entity]: $this.entityIdFk == $that.entityId && $this.date == %2024-01-01 && %2024-01-01 != $this.date, + trades[legal_entity, trade]: $this.entityId == $that.entityIdFk && $that.date == %2024-01-01 && %2024-01-01 != $that.date + } +) + +Mapping meta::external::store::relational::modelJoins::test::XStoreTradesMapping_withInequalities +( + include meta::external::store::relational::modelJoins::test::LegalEntityMapping + include meta::external::store::relational::modelJoins::test::TradesMapping + + meta::external::store::relational::modelJoins::test::Trade_LegalEntity: XStore + { + client[trade, legal_entity]: ($this.value >= $that.value) && ($this.value > $that.value) && ($this.value <= $that.value) && ($this.value < $that.value), + trades[legal_entity, trade]: ($that.value >= $this.value) && ($that.value > $this.value) && ($that.value <= $this.value) && ($that.value < $this.value) + } +) diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/tests/platformOperations/testPlatformOperationsOnRelational.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/tests/platformOperations/testPlatformOperationsOnRelational.pure new file mode 100644 index 00000000000..f3480e6dc82 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/tests/platformOperations/testPlatformOperationsOnRelational.pure @@ -0,0 +1,83 @@ + +import meta::pure::profiles::*; +import meta::pure::mapping::*; +import meta::pure::profiles::*; + + +function <> meta::relational::tests::platform::operations::testIsNotEmptyForRelational_returnsTrue():Boolean[1] +{ + //CreateAndFill + meta::relational::tests::platform::operations::createTablesAndFillDbUS(); + + let finalQuery = + {| + + let employees = meta::relational::tests::platform::operations::Person.all() + ->filter( x | $x.region =='NYC')->from(meta::relational::tests::platform::operations::mapping::EmployeeUSMapping,meta::relational::tests::platform::operations::runtime::testRuntimeUS()); + + $employees->isNotEmpty(); + }; + + let result = meta::legend::executeLegendQuery($finalQuery,[],^meta::pure::runtime::ExecutionContext(),meta::relational::extension::relationalExtensions()); + assertEquals('true', $result); +} + +function <> meta::relational::tests::platform::operations::testIsNotEmptyForRelational_returnsFalse():Boolean[1] +{ + //CreateAndFill + meta::relational::tests::platform::operations::createTablesAndFillDbUS(); + + + let finalQuery = + {| + + let employees = meta::relational::tests::platform::operations::Person.all() + ->filter( x | $x.region =='Chennai')->from(meta::relational::tests::platform::operations::mapping::EmployeeUSMapping,meta::relational::tests::platform::operations::runtime::testRuntimeUS()); + + $employees->isNotEmpty(); + }; + + let result = meta::legend::executeLegendQuery($finalQuery,[],^meta::pure::runtime::ExecutionContext(),meta::relational::extension::relationalExtensions()); + assertEquals('false', $result); + +} + +function <> meta::relational::tests::platform::operations::testIsEmptyForRelational_returnsFalse():Boolean[1] +{ + //CreateAndFill + meta::relational::tests::platform::operations::createTablesAndFillDbUS(); + + + let finalQuery = + {| + + let employees = meta::relational::tests::platform::operations::Person.all() + ->filter( x | $x.region =='NYC')->from(meta::relational::tests::platform::operations::mapping::EmployeeUSMapping,meta::relational::tests::platform::operations::runtime::testRuntimeUS()); + + $employees->isEmpty(); + }; + + let result = meta::legend::executeLegendQuery($finalQuery,[],^meta::pure::runtime::ExecutionContext(),meta::relational::extension::relationalExtensions()); + assertEquals('false', $result); + +} + +function <> meta::relational::tests::platform::operations::testIsEmptyForRelational_returnsTrue():Boolean[1] +{ + //CreateAndFill + meta::relational::tests::platform::operations::createTablesAndFillDbUS(); + + + let finalQuery = + {| + + let employees = meta::relational::tests::platform::operations::Person.all() + ->filter( x | $x.region =='Chennai')->from(meta::relational::tests::platform::operations::mapping::EmployeeUSMapping,meta::relational::tests::platform::operations::runtime::testRuntimeUS()); + + $employees->isEmpty(); + }; + + let result = meta::legend::executeLegendQuery($finalQuery,[],^meta::pure::runtime::ExecutionContext(),meta::relational::extension::relationalExtensions()); + assertEquals('true', $result); + +} \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/tests/platformOperations/testSetup.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/tests/platformOperations/testSetup.pure new file mode 100644 index 00000000000..6836469e298 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/tests/platformOperations/testSetup.pure @@ -0,0 +1,84 @@ +Class meta::relational::tests::platform::operations::Person +{ + firstName: String[1]; + lastName: String[*]; + isDataEng:Boolean[1]; + region:String[1]; +} + +function meta::relational::tests::platform::operations::createTablesAndFillDbUS():Boolean[1] +{ + let connection = meta::relational::tests::platform::operations::runtime::testRuntimeUS().connectionByElement(meta::relational::tests::platform::operations::database::EmployeeUSDB)->cast(@meta::external::store::relational::runtime::TestDatabaseConnection); + meta::relational::metamodel::execute::executeInDb('Drop table if exists Person;', $connection); + meta::relational::metamodel::execute::executeInDb('Create Table Person(PKEY INT PRIMARY KEY,FIRST_NAME VARCHAR(200),LAST_NAME VARCHAR(200),IS_FULLTIME BOOLEAN,REGION VARCHAR(200));', $connection); + meta::relational::metamodel::execute::executeInDb('insert into Person (PKEY, FIRST_NAME, LAST_NAME,IS_FULLTIME,REGION) values (1,\'John\', \'Smith\',True, \'NYC\');', $connection); + meta::relational::metamodel::execute::executeInDb('insert into Person (PKEY, FIRST_NAME, LAST_NAME,IS_FULLTIME,REGION) values (2,\'Jane\', \'Doe\',True, \'Chicago\');', $connection); + meta::relational::metamodel::execute::executeInDb('insert into Person (PKEY, FIRST_NAME, LAST_NAME,IS_FULLTIME,REGION) values (3,\'Christopher\', \'Nolan\',True, \'NYC\');', $connection); + true; +} + +###Relational +Database meta::relational::tests::platform::operations::database::EmployeeUSDB +( + Table Person ( + PKEY INT PRIMARY KEY, + FIRST_NAME VARCHAR(200) , + LAST_NAME VARCHAR(200) , + IS_FULLTIME BIT, + REGION VARCHAR(200) + ) +) + + +###Mapping +import meta::relational::tests::*; +import meta::external::store::relational::tests::*; +import meta::relational::tests::model::simple::*; + +Mapping meta::relational::tests::platform::operations::mapping::EmployeeUSMapping +( + meta::relational::tests::platform::operations::Person: Relational{ + ~primaryKey + ( + [meta::relational::tests::platform::operations::database::EmployeeUSDB]Person.PKEY + ) + ~mainTable [meta::relational::tests::platform::operations::database::EmployeeUSDB]Person + firstName:[meta::relational::tests::platform::operations::database::EmployeeUSDB]Person.FIRST_NAME, + lastName: [meta::relational::tests::platform::operations::database::EmployeeUSDB]Person.LAST_NAME, + isDataEng: [meta::relational::tests::platform::operations::database::EmployeeUSDB]Person.IS_FULLTIME, + region: [meta::relational::tests::platform::operations::database::EmployeeUSDB]Person.REGION + } +) + + +###Pure +import meta::relational::metamodel::*; +import meta::json::*; +import meta::json::tests::*; +import meta::relational::tests::*; +import meta::external::store::relational::tests::*; +import meta::pure::profiles::*; +import meta::relational::metamodel::execute::*; +import meta::core::runtime::*; +import meta::external::store::relational::runtime::*; +import meta::relational::runtime::*; + + +function meta::relational::tests::platform::operations::runtime::testRuntimeUS():Runtime[1] +{ + ^Runtime(connectionStores = meta::relational::tests::platform::operations::testDatabaseConnectionPerson(meta::relational::tests::platform::operations::database::EmployeeUSDB,'GMT')) +} + +function meta::relational::tests::platform::operations::testDatabaseConnectionPerson(db:Database[1], timeZone:String[0..1]) : ConnectionStore[1] +{ + ^ConnectionStore( + connection = ^meta::external::store::relational::runtime::TestDatabaseConnection( + type = DatabaseType.H2, + timeZone = if($timeZone->isEmpty(), |'GMT', |$timeZone) + ), + element = $db); +} + + + + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-javaPlatformBinding-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-javaPlatformBinding-pure/pom.xml index a3a75d55c8a..091cff9611e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-javaPlatformBinding-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-javaPlatformBinding-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/pom.xml b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/pom.xml index 994ab37e4db..0a32ce949b9 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/pom.xml +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/pom.xml @@ -19,7 +19,7 @@ org.finos.legend.engine legend-engine-xt-relationalStore-pure - 4.62.2-SNAPSHOT + 4.65.3-SNAPSHOT 4.0.0 @@ -123,13 +123,17 @@ org.finos.legend.pure legend-pure-runtime-java-engine-compiled + + + org.finos.legend.engine legend-engine-pure-platform-java - - - + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-unclassified + org.finos.legend.engine legend-engine-pure-code-compiled-core diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation.definition.json b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation.definition.json index a79c88db8b3..649ebfe67ab 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation.definition.json +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation.definition.json @@ -3,6 +3,15 @@ "pattern": "(meta::external::store::relational::sqlDialectTranslation)(::.*)?", "dependencies": [ "platform", + "platform_dsl_store", + "platform_dsl_mapping", + "platform_dsl_path", + "platform_dsl_graph", + "platform_dsl_diagram", + "platform_store_relational", + "core_functions_standard", + "core_functions_unclassified", + "core_functions_json", "core", "core_external_store_relational_postgres_sql_model" ] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation/defaults/sqlDialectDefaults.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation/defaults/sqlDialectDefaults.pure new file mode 100644 index 00000000000..bf6c5fa7714 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-sqlDialectTranslation-pure/src/main/resources/core_external_store_relational_sql_dialect_translation/defaults/sqlDialectDefaults.pure @@ -0,0 +1,729 @@ +// Copyright 2024 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 meta::external::query::sql::metamodel::*; +import meta::external::store::relational::sqlDialectTranslation::*; +import meta::external::store::relational::sqlDialectTranslation::defaults::*; +import meta::external::store::relational::sqlDialectTranslation::utils::*; + +Enum meta::external::store::relational::sqlDialectTranslation::defaults::SqlOperatorTypes_default +{ + DOT, // . + TYPECAST, // :: + ARRAY_ELEMENT_SELECTION, // [] + UNARY_PLUS_MINUS, // + , - + COLLATE, + AT, + EXPONENTIATION, // ^ + MULTIPLICATION_DIVISION_MODULO, // * , /, % + ADDITION_SUBTRACTION, // + , - + OTHER_NATIVE_USER_DEFINED_OPERATOR, + BETWEEN, + IN, + STRING_MATCH, // Like, Similar, Regex + BASIC_COMPARISON, // < > = <= >= <> + IS_CHECK, // IS NULL, IS NOT NULL, IS DISTINCT FROM etc. + NOT, + AND, + OR +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::findOperatorType_default(e: meta::external::query::sql::metamodel::Expression[1]): String[1] +{ + $e->match([ + {c: ComparisonExpression[1] | + if( + [ + pair(|$c.operator == ComparisonOperator.EQUAL, | SqlOperatorTypes_default.BASIC_COMPARISON), + pair(|$c.operator == ComparisonOperator.NOT_EQUAL, | SqlOperatorTypes_default.BASIC_COMPARISON), + pair(|$c.operator == ComparisonOperator.LESS_THAN, | SqlOperatorTypes_default.BASIC_COMPARISON), + pair(|$c.operator == ComparisonOperator.LESS_THAN_OR_EQUAL, | SqlOperatorTypes_default.BASIC_COMPARISON), + pair(|$c.operator == ComparisonOperator.GREATER_THAN, | SqlOperatorTypes_default.BASIC_COMPARISON), + pair(|$c.operator == ComparisonOperator.GREATER_THAN_OR_EQUAL, | SqlOperatorTypes_default.BASIC_COMPARISON), + pair(|$c.operator == ComparisonOperator.IS_DISTINCT_FROM, | SqlOperatorTypes_default.IS_CHECK), + pair(|$c.operator == ComparisonOperator.IS_NOT_DISTINCT_FROM, | SqlOperatorTypes_default.IS_CHECK), + pair(|$c.operator == ComparisonOperator.REGEX_MATCH, | SqlOperatorTypes_default.STRING_MATCH), + pair(|$c.operator == ComparisonOperator.REGEX_MATCH_CI, | SqlOperatorTypes_default.STRING_MATCH), + pair(|$c.operator == ComparisonOperator.REGEX_NO_MATCH, | SqlOperatorTypes_default.STRING_MATCH), + pair(|$c.operator == ComparisonOperator.REGEX_NO_MATCH_CI, | SqlOperatorTypes_default.STRING_MATCH), + pair(|$c.operator == ComparisonOperator.LIKE, | SqlOperatorTypes_default.STRING_MATCH), + pair(|$c.operator == ComparisonOperator.ILIKE, | SqlOperatorTypes_default.STRING_MATCH), + pair(|$c.operator == ComparisonOperator.NOT_LIKE, | SqlOperatorTypes_default.STRING_MATCH), + pair(|$c.operator == ComparisonOperator.NOT_ILIKE, | SqlOperatorTypes_default.STRING_MATCH) + ], + | fail('Unhandled comparator type: ' + $c.operator->toString()); SqlOperatorTypes_default.OTHER_NATIVE_USER_DEFINED_OPERATOR; + ); + }, + {l: LogicalBinaryExpression[1] | + if( + [ + pair(|$l.type == LogicalBinaryType.AND, | SqlOperatorTypes_default.AND), + pair(|$l.type == LogicalBinaryType.OR, | SqlOperatorTypes_default.OR) + ], + | fail('Unhandled logical binary expression type: ' + $l.type->toString()); SqlOperatorTypes_default.OTHER_NATIVE_USER_DEFINED_OPERATOR; + ); + }, + {l: NotExpression[1] | SqlOperatorTypes_default.NOT}, + {a: ArithmeticExpression[1] | + if( + [ + pair(|$a.type == ArithmeticType.ADD, | SqlOperatorTypes_default.ADDITION_SUBTRACTION), + pair(|$a.type == ArithmeticType.SUBTRACT, | SqlOperatorTypes_default.ADDITION_SUBTRACTION), + pair(|$a.type == ArithmeticType.MULTIPLY, | SqlOperatorTypes_default.MULTIPLICATION_DIVISION_MODULO), + pair(|$a.type == ArithmeticType.DIVIDE, | SqlOperatorTypes_default.MULTIPLICATION_DIVISION_MODULO), + pair(|$a.type == ArithmeticType.MODULUS, | SqlOperatorTypes_default.MULTIPLICATION_DIVISION_MODULO), + pair(|$a.type == ArithmeticType.POWER, | SqlOperatorTypes_default.EXPONENTIATION) + ], + | fail('Unhandled arithemtic expression type: ' + $a.type->toString()); SqlOperatorTypes_default.OTHER_NATIVE_USER_DEFINED_OPERATOR; + ); + }, + {q: QualifiedNameReference[1] | SqlOperatorTypes_default.DOT}, + {i: IsNullPredicate[1] | SqlOperatorTypes_default.IS_CHECK}, + {i: IsNotNullPredicate[1] | SqlOperatorTypes_default.IS_CHECK}, + {i: NegativeExpression[1] | SqlOperatorTypes_default.UNARY_PLUS_MINUS}, + {i: InPredicate[1] | SqlOperatorTypes_default.IN}, + {b: BetweenPredicate[1] | SqlOperatorTypes_default.BETWEEN}, + a: meta::external::query::sql::metamodel::Expression[1] | fail('Unknown expression type - ' + $e->class()->elementToPath()); SqlOperatorTypes_default.OTHER_NATIVE_USER_DEFINED_OPERATOR; + ])->toString() +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::operatorPrecedence_default(): Map[1] +{ + // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-PRECEDENCE + + let operatorPrecedenceOrder = [ + SqlOperatorTypes_default.DOT->toString(), + SqlOperatorTypes_default.TYPECAST->toString(), + SqlOperatorTypes_default.ARRAY_ELEMENT_SELECTION->toString(), + SqlOperatorTypes_default.UNARY_PLUS_MINUS->toString(), + SqlOperatorTypes_default.COLLATE->toString(), + SqlOperatorTypes_default.AT->toString(), + SqlOperatorTypes_default.EXPONENTIATION->toString(), + SqlOperatorTypes_default.MULTIPLICATION_DIVISION_MODULO->toString(), + SqlOperatorTypes_default.ADDITION_SUBTRACTION->toString(), + SqlOperatorTypes_default.OTHER_NATIVE_USER_DEFINED_OPERATOR->toString(), + SqlOperatorTypes_default.BETWEEN->toString(), + SqlOperatorTypes_default.IN->toString(), + SqlOperatorTypes_default.STRING_MATCH->toString(), + SqlOperatorTypes_default.BASIC_COMPARISON->toString(), + SqlOperatorTypes_default.IS_CHECK->toString(), + SqlOperatorTypes_default.NOT->toString(), + SqlOperatorTypes_default.AND->toString(), + SqlOperatorTypes_default.OR->toString() + ]; + + $operatorPrecedenceOrder->zip($operatorPrecedenceOrder->size()->range())->newMap(); +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::identifierProcessor_default(): IdentifierProcessor[1] +{ + identifierProcessor + ( + {sqlDialect, identifier, shouldQuote, state, config | + if ($shouldQuote || $identifier->in($sqlDialect.keywords), + | if ($sqlDialect.quoteConfig->isEmpty(), + | // Quoting configuration unknown. Hence returning the identifier as is + $identifier, + | let quoteCfg = $sqlDialect.quoteConfig->toOne(); + $quoteCfg.start + $identifier->replace($quoteCfg.end, $quoteCfg.escape) + $quoteCfg.end; + ), + | $identifier + ) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::integerLiteralNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + IntegerLiteral, + {sqlDialect, i, state, config | + $i.value->toString() + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::stringLiteralNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + StringLiteral, + {sqlDialect, s, state, config | + '\'' + $s.value->replace('\'', '\'\'') + '\'' + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::booleanLiteralNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + BooleanLiteral, + {sqlDialect, s, state, config | + $sqlDialect->keyword(if($s.value , | 'true', | 'false'), $state, $config) + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::longLiteralNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + LongLiteral, + {sqlDialect, l, state, config | + $l.value->toString() + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::doubleLiteralNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + DoubleLiteral, + {sqlDialect, d, state, config | + $d.value->toString() + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::nullLiteralNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + NullLiteral, + {sqlDialect, d, state, config | + $sqlDialect->keyword('null', $state, $config) + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::allColumnsNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + AllColumns, + {sqlDialect, a, state, config | + let prefix = if ($a.prefix->isNotEmpty(), | $sqlDialect->executeIdentifierProcessor($a.prefix->toOne(), false, $state, $config) + '.', | ''); + $prefix + '*'; + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::singleColumnNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + SingleColumn, + {sqlDialect, s, state, config | + let suffix = if ($s.alias->isNotEmpty(), + | ' ' + $sqlDialect->keyword('as', $state, $config) + ' ' + $sqlDialect->executeIdentifierProcessor($s.alias->toOne(), false, $state, $config), + | '' + ); + $sqlDialect->executeNodeProcessor($s.expression, $state, $config) + $suffix; + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::comparisonExpressionNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + ComparisonExpression, + {sqlDialect, c, state, config | + let leftExpr = $sqlDialect->executeNodeProcessor($c.left, $c, $state, $config); + let rightExpr = $sqlDialect->executeNodeProcessor($c.right, $c, $state, $config); + let comparator = if( + [ + pair(|$c.operator == ComparisonOperator.EQUAL, | '='), + pair(|$c.operator == ComparisonOperator.NOT_EQUAL, | '<>'), + pair(|$c.operator == ComparisonOperator.LESS_THAN, | '<'), + pair(|$c.operator == ComparisonOperator.LESS_THAN_OR_EQUAL, | '<='), + pair(|$c.operator == ComparisonOperator.GREATER_THAN, | '>'), + pair(|$c.operator == ComparisonOperator.GREATER_THAN_OR_EQUAL, | '>='), + pair(|$c.operator == ComparisonOperator.IS_DISTINCT_FROM, | $sqlDialect->keyword('is distinct from', $state, $config)), + pair(|$c.operator == ComparisonOperator.IS_NOT_DISTINCT_FROM, | $sqlDialect->keyword('is not distinct from', $state, $config)), + pair(|$c.operator == ComparisonOperator.REGEX_MATCH, | '~'), + pair(|$c.operator == ComparisonOperator.REGEX_MATCH_CI, | '~*'), + pair(|$c.operator == ComparisonOperator.REGEX_NO_MATCH, | '!~'), + pair(|$c.operator == ComparisonOperator.REGEX_NO_MATCH_CI, | '!~*'), + pair(|$c.operator == ComparisonOperator.LIKE, | '~~'), + pair(|$c.operator == ComparisonOperator.ILIKE, | '~~*'), + pair(|$c.operator == ComparisonOperator.NOT_LIKE, | '!~~'), + pair(|$c.operator == ComparisonOperator.NOT_ILIKE, | '!~~*') + ], + | failWithMessage('Unhandled comparator type: ' + $c.operator->toString()) + ); + + $leftExpr + ' ' + $comparator + ' ' + $rightExpr; + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::logicalBinaryExpressionNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + LogicalBinaryExpression, + {sqlDialect, l, state, config | + let leftExpr = $sqlDialect->executeNodeProcessor($l.left, $l, $state, $config); + let rightExpr = $sqlDialect->executeNodeProcessor($l.right, $l, $state, $config); + if( + [ + pair(|$l.type == LogicalBinaryType.AND, | $leftExpr + ' ' + $sqlDialect->keyword('and', $state, $config) + ' ' + $rightExpr;), + pair(|$l.type == LogicalBinaryType.OR, | $leftExpr + ' ' + $sqlDialect->keyword('or', $state, $config) + ' ' + $rightExpr;) + ], + | failWithMessage('Unhandled binary expression type: ' + $l.type->toString()) + ); + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::notExpressionNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + NotExpression, + {sqlDialect, e, state, config | + $sqlDialect->keyword('not', $state, $config) + ' ' + $sqlDialect->executeNodeProcessor($e.value, $e, $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::arithmeticExpressionNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + ArithmeticExpression, + {sqlDialect, a, state, config | + let isDivide = $a->isDivideExpr(); + let castAsDecimalIfDivide = {e: meta::external::query::sql::metamodel::Expression[1] | + if ($isDivide, | ^Cast(type = ^ColumnType(name = 'decimal'), expression = $e), | $e) + }; + let leftExpr = $sqlDialect->executeNodeProcessor($castAsDecimalIfDivide->eval($a.left), $a, $state, $config); + let rightExpr = $sqlDialect->executeNodeProcessor($castAsDecimalIfDivide->eval($a.right), $a, $state, $config); + let operator = if( + [ + pair(|$a.type == ArithmeticType.ADD, | '+'), + pair(|$a.type == ArithmeticType.SUBTRACT, | '-'), + pair(|$a.type == ArithmeticType.MULTIPLY, | '*'), + pair(|$a.type == ArithmeticType.DIVIDE, | '/'), + pair(|$a.type == ArithmeticType.MODULUS, | '%'), + pair(|$a.type == ArithmeticType.POWER, | '^') + ], + | failWithMessage('Unhandled arithmetic operator type: ' + $a.type->toString()) + ); + + $leftExpr + ' ' + $operator + ' ' + $rightExpr; + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::qualifiedNameReferenceNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + QualifiedNameReference, + {sqlDialect, q, state, config | + $sqlDialect->qualifiedName($q.name, $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::isNullPredicateNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + IsNullPredicate, + {sqlDialect, e, state, config | + $sqlDialect->executeNodeProcessor($e.value, $e, $state, $config) + ' ' + $sqlDialect->keyword('is null', $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::isNotNullPredicateNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + IsNotNullPredicate, + {sqlDialect, e, state, config | + $sqlDialect->executeNodeProcessor($e.value, $e, $state, $config) + ' ' + $sqlDialect->keyword('is not null', $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::negativeNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + NegativeExpression, + {sqlDialect, e, state, config | + '-' + $sqlDialect->executeNodeProcessor($e.value, $e, $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::currentTimeNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + CurrentTime, + {sqlDialect, c, state, config | + let type = if( + [ + pair(|$c.type == CurrentTimeType.TIME, | $sqlDialect->keyword('current_time', $state, $config)), + pair(|$c.type == CurrentTimeType.TIMESTAMP, | $sqlDialect->keyword('current_timestamp', $state, $config)), + pair(|$c.type == CurrentTimeType.DATE, | $sqlDialect->keyword('current_date', $state, $config)) + ], + | failWithMessage('Unhandled current time type: ' + $c.type->toString()) + ); + let precision = if ($c.precision->isNotEmpty(), | '(' + $c.precision->toOne()->toString() + ')', | ''); + $type + $precision; + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::whenClauseNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + WhenClause, + {sqlDialect, w, state, config | + let sep0 = $state.separator(0, $config); + let sep1 = $state.separator(1, $config); + $sqlDialect->keyword('when', $state, $config) + $sep1 + $sqlDialect->executeNodeProcessor($w.operand, [], $state->increaseLevel(), $config) + + $sep0 + $sqlDialect->keyword('then', $state, $config) + $sep1 + $sqlDialect->executeNodeProcessor($w.result, [], $state->increaseLevel(), $config); + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::searchedCaseExpressionNodeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + SearchedCaseExpression, + {sqlDialect, c, state, config | + let sep0 = $state.separator(0, $config); + let sep1 = $state.separator(1, $config); + let sep2 = $state.separator(2, $config); + let default = if ($c.defaultValue->isNotEmpty(), + | $sep1 + $sqlDialect->keyword('else', $state, $config) + + $sep2 + $sqlDialect->executeNodeProcessor($c.defaultValue->toOne(), [], $state->increaseLevel()->increaseLevel(), $config), + | '' + ); + let whenClauses = $c.whenClauses->map(w | $sqlDialect->executeNodeProcessor($w, [], $state->increaseLevel(), $config))->joinStrings($sep1); + $sqlDialect->keyword('case', $state, $config) + $sep1 + $whenClauses + $default + $sep0 + $sqlDialect->keyword('end', $state, $config); + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::columnTypeProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + ColumnType, + {sqlDialect, c, state, config | + $sqlDialect->keyword($c.name, $state, $config) + + if ($c.parameters->isNotEmpty(), | $c.parameters->map(p | $p->toString())->joinStrings('(', ', ', ')'), | ''); + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::castProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + Cast, + {sqlDialect, c, state, config | + $sqlDialect->keyword('cast', $state, $config) + '(' + $sqlDialect->executeNodeProcessor($c.expression, [], $state, $config) + ' ' + + $sqlDialect->keyword('as', $state, $config) + ' ' + $sqlDialect->executeNodeProcessor($c.type, [], $state, $config) + ')' + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::inListExpressionProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + InListExpression, + {sqlDialect, l, state, config | + let sep0 = $state.separatorIfPretty(0, $config); + let sep1 = $state.separatorIfPretty(1, $config); + let whenClauses = $l.values->map(v | $sqlDialect->executeNodeProcessor($v, [], $state->increaseLevel(), $config))->joinStrings(',' + $state.separator(1, $config)); + '(' + $sep1 + $whenClauses + $sep0 + ')'; + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::inPredicateProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + InPredicate, + {sqlDialect, i, state, config | + $sqlDialect->executeNodeProcessor($i.value, $i, $state, $config) + ' ' + $sqlDialect->keyword('in', $state, $config) + ' ' + + $sqlDialect->executeNodeProcessor($i.valueList, $i, $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::extractProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + Extract, + {sqlDialect, e, state, config | + $sqlDialect->keyword('extract', $state, $config) + '(' + $sqlDialect->keyword($e.field.name->toLower(), $state, $config) + ' ' + + $sqlDialect->keyword('from', $state, $config) + ' ' + $sqlDialect->executeNodeProcessor($e.expression, [], $state, $config) + ')'; + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::betweenPredicateProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + BetweenPredicate, + {sqlDialect, b, state, config | + $sqlDialect->executeNodeProcessor($b.value, $b, $state, $config) + ' ' + $sqlDialect->keyword('between', $state, $config) + ' ' + + $sqlDialect->executeNodeProcessor($b.min, $b, $state, $config) + ' ' + $sqlDialect->keyword('and', $state, $config) + ' ' + $sqlDialect->executeNodeProcessor($b.max, $b, $state, $config); + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::sortItemProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + SortItem, + {sqlDialect, s, state, config | + $sqlDialect->executeNodeProcessor($s.sortKey, [], $state, $config) + ' ' + + if( + [ + pair(|$s.ordering == SortItemOrdering.ASCENDING, | $sqlDialect->keyword('asc', $state, $config)), + pair(|$s.ordering == SortItemOrdering.DESCENDING, | $sqlDialect->keyword('desc', $state, $config)) + ], + | failWithMessage('Unhandled sort item ordering type: ' + $s.ordering->toString()) + ) + + if( + [ + pair(|$s.nullOrdering == SortItemNullOrdering.FIRST, | ' ' + $sqlDialect->keyword('nulls first', $state, $config)), + pair(|$s.nullOrdering == SortItemNullOrdering.LAST, | ' ' + $sqlDialect->keyword('nulls last', $state, $config)), + pair(|$s.nullOrdering == SortItemNullOrdering.UNDEFINED, | '') + ], + | failWithMessage('Unhandled sort item null ordering type: ' + $s.nullOrdering->toString()) + ); + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::windowProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + meta::external::query::sql::metamodel::Window, + {sqlDialect, w, state, config | + let sep0 = $state.separator(0, $config); + let sep1 = $state.separator(1, $config); + if ($w.windowRef->isNotEmpty(), + | $w.windowRef->toOne(), + | let partitions = if ($w.partitions->isNotEmpty(), + | $sqlDialect->keyword('partition by', $state, $config) + $sep1 + $w.partitions->map(p | $sqlDialect->executeNodeProcessor($p, [], $state->increaseLevel(), $config))->joinStrings(',' + $sep1), + | '' + ); + let orderBy = if ($w.orderBy->isNotEmpty(), + | let sep = if ($w.partitions->isNotEmpty(), | $sep0, | ''); + $sep + $sqlDialect->keyword('order by', $state, $config) + $sep1 + $w.orderBy->map(o | $sqlDialect->executeNodeProcessor($o, [], $state->increaseLevel(), $config))->joinStrings(',' + $sep1);, + | '' + ); + assert($w.windowFrame->isEmpty(), | 'Window frame processing not implemented yet'); + $partitions + $orderBy; + ); + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::functionCallProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + FunctionCall, + {sqlDialect, f, state, config | + assert($f.distinct == false, | 'Distinct function call processing not implemented yet'); + assert($f.filter->isEmpty(), | 'Filtered function call processing not implemented yet'); + assert($f.group->isEmpty(), | 'Grouped function call processing not implemented yet'); + assert($f.orderBy->isEmpty(), | 'Sorted function call processing not implemented yet'); + + let sep0 = $state.separatorIfPretty(0, $config); + let sep1 = $state.separatorIfPretty(1, $config); + + $sqlDialect->qualifiedName($f.name, $state, $config) + '(' + if($f.arguments->isEmpty(), | '', | $sep1) + + $f.arguments->map(a | $sqlDialect->executeNodeProcessor($a, [], $state->increaseLevel(), $config))->joinStrings(',' + $state.separator(1, $config)) + + + if($f.arguments->isEmpty(), | '', | $sep0) + ')' + + if ($f.window->isNotEmpty(), + | ' ' + $sqlDialect->keyword('over', $state, $config) + ' (' + $sep1 + $sqlDialect->executeNodeProcessor($f.window->toOne(), [], $state->increaseLevel(), $config) + $sep0 + ')', + | '' + ); + }, + {n | true} + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::tableProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + Table, + {sqlDialect, t, state, config | + $sqlDialect->qualifiedName($t.name, $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::aliasedRelationProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + AliasedRelation, + {sqlDialect, a, state, config | + $sqlDialect->executeNodeProcessor($a.relation, $state, $config) + ' ' + $sqlDialect->keyword('as', $state, $config) + ' ' + + $sqlDialect->executeIdentifierProcessor($a.alias, false, $state, $config) + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::joinProcessor_default(): NodeProcessor[1] +{ + nodeProcessor( + Join, + {sqlDialect, j, state, config | + let sep0 = $state.separator(0, $config); + let sep1 = $state.separator(1, $config); + let left = $sqlDialect->executeNodeProcessor($j.left, $state, $config); + let right = $sqlDialect->executeNodeProcessor($j.right, $state->increaseLevel(), $config); + let type = if( + [ + pair(|$j.type == JoinType.CROSS, | $sqlDialect->keyword('cross join', $state, $config)), + pair(|$j.type == JoinType.LEFT, | $sqlDialect->keyword('left outer join', $state, $config)), + pair(|$j.type == JoinType.RIGHT, | $sqlDialect->keyword('right outer join', $state, $config)), + pair(|$j.type == JoinType.INNER, | $sqlDialect->keyword('inner join', $state, $config)) + ], + | failWithMessage('Unhandled join type: ' + $j.type->toString()) + ); + let isNaturalJoin = $j.criteria->isNotEmpty() && $j.criteria->toOne()->instanceOf(NaturalJoin); + + $left + $sep0 + if($isNaturalJoin, | $sqlDialect->keyword('natural', $state, $config) + ' ', | '') + $type + + $sep1 + $right + + if ($j.criteria->isNotEmpty() && (!$isNaturalJoin), + | $sep1 + $sqlDialect->keyword('on', $state, $config) + ' ' + + $j.criteria->toOne()->match([ + o: JoinOn[1] | '(' + $sqlDialect->executeNodeProcessor($o.expression, $state, $config) + ')', + a: Any[*] | failWithMessage('Unhandled join criteria: ' + $a->class()->elementToPath()) + ]), + | '' + ); + } + ) +} + +function meta::external::store::relational::sqlDialectTranslation::defaults::selectProcessor_default(): NodeProcessor