From b2c1e84114bb2cbb90a99b2da2500149931be554 Mon Sep 17 00:00:00 2001 From: afine-gs Date: Tue, 5 Nov 2024 13:53:13 -0500 Subject: [PATCH] testWrapper --- .../core/pure/lineage/lineageModel.pure | 80 +++++++++++++++++ .../tests/testWrapper.pure | 89 ------------------- 2 files changed, 80 insertions(+), 89 deletions(-) create mode 100644 legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/lineageModel.pure delete mode 100644 legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/testWrapper.pure diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/lineageModel.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/lineageModel.pure new file mode 100644 index 00000000000..e500fda28f1 --- /dev/null +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/lineage/lineageModel.pure @@ -0,0 +1,80 @@ +// 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. + + +Class meta::pure::lineage::report::Source +{ + <> context: String[1]; +} + +Class meta::pure::lineage::report::PropertySource extends meta::pure::lineage::report::Source +{ + <> classPath: String[1]; + <> propertyName: String[1]; +} + + +Class meta::pure::lineage::graph::Node +{ + data : meta::pure::lineage::graph::NodeData[1]; +} + +Class meta::pure::lineage::graph::NodeData +{ + id : String[1]; + text : String[1]; + type : String[1]; + displayType : String[0..1]; + parent : meta::pure::lineage::graph::Node[0..1]; +} + +Class meta::pure::lineage::graph::Edge +{ + data : meta::pure::lineage::graph::EdgeData[1]; +} + +Class meta::pure::lineage::graph::EdgeData +{ + id : String[1]; + text : String[1]; + type : String[1]; + source : meta::pure::lineage::graph::Node[1]; + target : meta::pure::lineage::graph::Node[1]; +} + +Class meta::pure::lineage::graph::Graph +{ + nodes : meta::pure::lineage::graph::Node[*]; + edges : meta::pure::lineage::graph::Edge[*]; +} + +Class meta::pure::lineage::result::PropertyLineage +{ + propertyName : String[1]; + resultDetail : String[1]; +} + +Class meta::pure::lineage::result::ResultLineage +{ + properties : meta::pure::lineage::result::PropertyLineage[*]; +} + + +Class meta::pure::lineage::result::LineageResult +{ + storeLineage: meta::pure::lineage::graph::Graph[1]; + classLineage: meta::pure::lineage::graph::Graph[1]; + resultLineage : meta::pure::lineage::result::ResultLineage[1]; +} + 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/testWrapper.pure b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/testWrapper.pure deleted file mode 100644 index 2a58588341a..00000000000 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/tests/testWrapper.pure +++ /dev/null @@ -1,89 +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. - -###Pure -import meta::pure::lineage::*; -import meta::analytics::lineage::*; -import meta::relational::tests::model::simple::*; -import meta::relational::tests::mapping::association::embedded::*; -function meta::pure::lineage::test::testPersonToOrganisationsExample():Boolean[1] -{ - meta::relational::tests::mapping::association::embedded::setUp(); - let result = testWrapper(|Person.all()->project([p|$p.lastName,p|$p.firm.legalName, p|$p.firm.organizations.name], ['name', 'firm', 'team']), associationMapping, meta::external::store::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - let lineage = $result->meta::pure::lineage::test::getLineage(); - assertLineage(['Lambda', 'db_myDB', 'tb_myDBdefaultORGANIZATIONS', 'tb_myDBdefaultPERSON_FIRM_DENORM'], ['Lambda', 'meta::relational::tests::model::simple::Firm', 'meta::relational::tests::model::simple::Organization', 'meta::relational::tests::model::simple::Person', 'pack_meta::relational::tests::model::simple'],'[firm: [PERSON_FIRM_DENORM.FIRM_LEGALNAME ], name: [PERSON_FIRM_DENORM.PERSON_LASTNAME ], team: [ORGANIZATIONS.FIRM_ID , ORGANIZATIONS.NAME , PERSON_FIRM_DENORM.FIRM_ID ]]',$lineage); - let tds= $result->getTabularDatasetResult().values->at(0); - assertEquals(5, $tds.rows->size()); - assertSameElements(['Smith Firm X Team 1', 'Smith Firm X Team 2', 'Johnson Firm X Team 1', 'Johnson Firm X Team 2', 'Roberts Firm A Team 3'], $tds.rows->map(r|$r.getString('name')+' '+$r.getString('firm')->toString()+ ' ' +$r.getString('team'))); -} - - - -###Pure -import meta::analytics::lineage::*; -import meta::core::runtime::*; -import meta::pure::mapping::*; -import meta::pure::lineage::test::*; -function meta::pure::lineage::test::getLineage(result:Map[1]):FunctionAnalytics[1] -{ -$result->get('lineage')->cast(@LineageResult).result->toOne(); - -} - -function meta::pure::lineage::getTabularDatasetResult(result:Map[1]):meta::pure::mapping::Result[1] -{ -$result->get('executeResult')->cast(@ExecuteResult).result->toOne(); - -} - -function meta::pure::lineage::testWrapper(f:FunctionDefinition<{->T[y]}>[1], m:Mapping[1], runtime:Runtime[1], extensions:meta::pure::extension::Extension[*]):Map[1] -{ - - newMap([meta::pure::lineage::test::executeWrapper($f,$m,$runtime,$extensions), - meta::pure::lineage::test::lineageWrapper($f,$m,$runtime,$extensions) - ] - ); - -} - - -function meta::pure::lineage::test::executeWrapper(f:FunctionDefinition<{->T[y]}>[1], m:Mapping[1], runtime:Runtime[1], extensions:meta::pure::extension::Extension[*]):Pair[1] -{ - -pair('executeResult',^ExecuteResult(result=meta::pure::router::execute($f,$m,$runtime,$extensions))); - -} - -function meta::pure::lineage::test::lineageWrapper(f:FunctionDefinition<{->T[y]}>[1], m:Mapping[1], runtime:Runtime[1], extensions:meta::pure::extension::Extension[*]):Pair[1] -{ - -pair('lineage',^LineageResult(result=computeLineage($f,$m,$runtime,$extensions))); - -} - - -Class meta::pure::lineage::test::Result -{ - -} - -Class meta::pure::lineage::test::ExecuteResult extends meta::pure::lineage::test::Result -{ - result:meta::pure::mapping::Result[1]; - -} -Class meta::pure::lineage::test::LineageResult extends meta::pure::lineage::test::Result -{ - result:FunctionAnalytics[1]; -} \ No newline at end of file