diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/mapping/mappingExtension.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/mapping/mappingExtension.pure index 3e64d7b33b0..c7d4e176183 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/mapping/mappingExtension.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/mapping/mappingExtension.pure @@ -136,15 +136,17 @@ function meta::pure::mapping::allEnumerationMappings(m: Mapping[1]): Enumeration $m.enumerationMappings->concatenate($m.includes->map(i | $i.included->allEnumerationMappings())) } - - - - - - - - - +function meta::pure::mapping::allSuperSetImplementations(set :PropertyMappingsImplementation[1], m:Mapping[1]):PropertyMappingsImplementation[*] +{ + if ($set.superSetImplementationId->isEmpty(), + | [], + | let superMapping = $m->classMappingById($set.superSetImplementationId->toOne()); + if($superMapping->isEmpty(), + | [], + |$superMapping->toOne()->cast(@PropertyMappingsImplementation)->allSuperSetImplementations($m)->concatenate($superMapping->toOne()->cast(@PropertyMappingsImplementation)) + ); + ); +} function meta::pure::router::clustering::resolveInstanceSetImplementations(o:OperationSetImplementation[1]):InstanceSetImplementation[*] { diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/fullAnalytics.pure b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/fullAnalytics.pure index 27b62739e47..856246710f7 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/fullAnalytics.pure +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/fullAnalytics.pure @@ -236,7 +236,10 @@ function meta::analytics::lineage::flowDatabase::toFlowDatabase(p:PropertyPathTr , cl: Class[1]|if($disregardClass, |meta::analytics::lineage::flowDatabase::manageQualifiers($p.children, $extraChildren)->map(c|$c->toFlowDatabase($m, $sets, false, $extraChildren)), - |meta::analytics::lineage::flowDatabase::manageQualifiers($p.children, $extraChildren)->map(c|$c->toFlowDatabase($m, $m->rootClassMappingByClass($cl)->last()->meta::pure::router::routing::resolveOperation($m), false, $extraChildren)); + | + let sets = $m->_classMappingByClass($cl)->map(s|$s->meta::pure::router::routing::resolveOperation($m)); + let setsWithSuper = $sets->map(s|$s->allSuperSetImplementations($m))->concatenate($sets)->cast(@InstanceSetImplementation); + meta::analytics::lineage::flowDatabase::manageQualifiers($p.children, $extraChildren)->map(c|$c->toFlowDatabase($m, $setsWithSuper, false, $extraChildren)); );, a :Any[1]|meta::analytics::lineage::flowDatabase::manageQualifiers($p.children, $extraChildren)->map(c|$c->toFlowDatabase($m, $sets, $disregardClass, $extraChildren)) ]); 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 dad8cb95911..2264d2ea0c1 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 @@ -403,10 +403,29 @@ function <> meta::analytics::lineage::tests::relational::graphFetch:: let mapping = meta::relational::graphFetch::tests::union::propertyLevel::Mapping6; - let runtime = meta::external::store::relational::tests::testRuntime();let lineage = meta::analytics::lineage::computeLineage($query, $mapping, $runtime, meta::relational::extension::relationalExtensions()); + let runtime = meta::external::store::relational::tests::testRuntime(); + + let lineage = meta::analytics::lineage::computeLineage($query, $mapping, $runtime, meta::relational::extension::relationalExtensions()); meta::analytics::lineage::assertLineage(['Lambda', 'db_myDB', 'tb_myDBdefaultAddressSet1', 'tb_myDBdefaultAddressSet2', 'tb_myDBdefaultAddressSet3', 'tb_myDBdefaultFirmSet1', 'tb_myDBdefaultFirmSet2', 'tb_myDBdefaultFirmSet3', 'tb_myDBdefaultPersonSet1', 'tb_myDBdefaultPersonSet2', 'tb_myDBdefaultPersonSet3'], ['Lambda', 'meta::relational::tests::model::simple::Address', 'meta::relational::tests::model::simple::Firm', 'meta::relational::tests::model::simple::Person', 'pack_meta::relational::tests::model::simple'], '[Firm.employees.address.name: [AddressSet1.ID , AddressSet1.name , AddressSet2.ID , AddressSet2.name , AddressSet3.ID , AddressSet3.name , FirmSet1.ID , FirmSet2.ID , FirmSet3.ID , PersonSet1.ADDRESSID , PersonSet1.FirmID , PersonSet2.ADDRESSID , PersonSet2.FirmID , PersonSet3.ADDRESSID , PersonSet3.FirmID ], Firm.employees.lastName: [FirmSet1.ID , FirmSet2.ID , FirmSet3.ID , PersonSet1.FirmID , PersonSet1.lastName_s1 , PersonSet2.FirmID , PersonSet2.lastName_s2 , PersonSet3.FirmID , PersonSet3.lastName_s3 ], Firm.legalName: [FirmSet1.name , FirmSet2.name , FirmSet3.name ]]', $lineage); } + +###Pure +import meta::analytics::lineage::*; +import meta::pure::lineage::scanRelations::*; + +function <> meta::analytics::lineage::tests::relational::test::testMilestoneInheriteance():Boolean[1] +{ + let query = {| meta::relational::tests::milestoning::ProductWithConstraint1.all(%2022-02-02)-> project([f|$f.ascPnL.pnl], ['OrderID'])}; + let mapping = meta::relational::tests::milestoning::milestoningmapWithMappingExtensions; + + let lineage = meta::analytics::lineage::computeLineage($query, $mapping,meta::external::store::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); + meta::analytics::lineage::assertLineage(['Lambda', 'db_dbInclusion', 'db_dbWithInclusion', 'tb_dbInclusiondefaultProductTable', 'tb_dbWithInclusiondefaultOrderTable'], + ['Lambda', 'meta::relational::tests::milestoning::OrderPnl', 'meta::relational::tests::milestoning::ProductWithConstraint1', 'pack_meta::relational::tests::milestoning'], + '[OrderID: [OrderTable.pnl , OrderTable.prodFk , ProductTable.id ]]', + $lineage); +} + 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/scanColumns/scanColumns.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/scanColumns/scanColumns.pure index 3a7d180fd18..8e4e1d42bad 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/scanColumns/scanColumns.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/scanColumns/scanColumns.pure @@ -93,10 +93,11 @@ function <> meta::pure::lineage::scanColumns::scanColumns(p:Prop cl: Class[1]| print(if($debug.debug,|$debug.space+'Process Class: '+$cl.name->toOne()+'\n',|'')); if($isRoot, - | - let nClassToSets = if($classToSets->keys()->contains($cl), |$classToSets, | $classToSets->keyValues()->concatenate(pair($cl, list($m->_classMappingByClass($cl)->map(s|$s->resolveOperation($m)))))->newMap()); + | let sets = $m->_classMappingByClass($cl)->map(s|$s->resolveOperation($m)); + let setsWithSuper = $sets->map(s|$s->meta::pure::mapping::allSuperSetImplementations($m))->concatenate($sets)->cast(@InstanceSetImplementation); + let nClassToSets = if($classToSets->keys()->contains($cl), |$classToSets, | $classToSets->keyValues()->concatenate(pair($cl, list($setsWithSuper)))->newMap()); let nsets = $nClassToSets->get($cl).values; - $p.children->map(c|$c->scanColumns($m, $sets->concatenate($nsets)->removeDuplicatesBy(x | $x.id), $nClassToSets, $idToSet, false, ^$debug(space=$debug.space+' ')));, + $p.children->map(c|$c->scanColumns($m, $setsWithSuper->concatenate($nsets)->removeDuplicatesBy(x | $x.id), $nClassToSets, $idToSet, false, ^$debug(space=$debug.space+' ')));, | $p.children->map(c|$c->scanColumns($m, $sets, $classToSets, $idToSet, false, ^$debug(space=$debug.space+' '))););, a :Any[1]| 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/milestoning/tests/businessDateMilestoningSetUp.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/milestoning/tests/businessDateMilestoningSetUp.pure index d56060a1517..94a00989de9 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/milestoning/tests/businessDateMilestoningSetUp.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/milestoning/tests/businessDateMilestoningSetUp.pure @@ -1234,6 +1234,59 @@ Mapping meta::relational::tests::milestoning::viewFilter::MilestoningWithFilters } ) +###Mapping +import meta::relational::tests::milestoning::*; +Mapping meta::relational::tests::milestoning::milestoningmapWithMappingExtensionsInc +( + + meta::relational::tests::milestoning::ProductWithConstraint1[product1] extends [product]: Relational{ + val : [dbInclusion]ProductTable.name + } + + meta::relational::tests::milestoning::Product[product] : Relational{ + id : [dbInclusion]ProductTable.id + } + +) + + +Mapping meta::relational::tests::milestoning::milestoningmapWithMappingExtensions +( + include meta::relational::tests::milestoning::milestoningmapWithMappingExtensionsInc[dbInclusion->dbWithInclusion] + + meta::relational::tests::milestoning::OrderPnl[order] : Relational{ + pnl : [dbWithInclusion]OrderTable.pnl + } + + meta::relational::tests::milestoning::OrderPNLProduct: Relational + { + AssociationMapping + ( + ascPnL[product,order] : [dbWithInclusion]@Order_Product, + ascProduct[order,product] : [dbWithInclusion]@Order_Product + ) + + } + +) + +###Relational +Database meta::relational::tests::milestoning::dbWithInclusion( + include meta::relational::tests::milestoning::dbInclusion + + Table OrderTable(id Integer PRIMARY KEY, orderDate DATE, prodFk Integer, pnl Integer) + Join Order_Product(OrderTable.prodFk=ProductTable.id) + +) + + +###Relational +Database meta::relational::tests::milestoning::dbInclusion( + + Table ProductTable(id Integer PRIMARY KEY, orderDate DATE, name VARCHAR(255), prodFk Integer) +) + + ###Relational Database meta::relational::tests::milestoning::ViewChainDb ( 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/milestoning/tests/milestoningModel.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/milestoning/tests/milestoningModel.pure index 577d42a15e8..8e80fe215d3 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/milestoning/tests/milestoningModel.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/milestoning/tests/milestoningModel.pure @@ -141,6 +141,7 @@ Class <> meta::relational::tests::milestoning::Produc ) ] { + val:String[0..1]; } Class <> meta::relational::tests::milestoning::ProductWithConstraint1b extends meta::relational::tests::milestoning::Product @@ -299,6 +300,11 @@ Association meta::relational::tests::milestoning::OrderProduct{ orders : Order[*]; } +Association meta::relational::tests::milestoning::OrderPNLProduct{ + ascProduct : Product[1]; + ascPnL : OrderPnl[1]; +} + Class <> meta::relational::tests::milestoning::inheritance::VehicleOwner { vehicles : Vehicle[*]; 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/mapping/extends/testExtendsForMainTable.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/mapping/extends/testExtendsForMainTable.pure index 1ee24fe1d03..d4f67352744 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/tests/mapping/extends/testExtendsForMainTable.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/mapping/extends/testExtendsForMainTable.pure @@ -101,3 +101,11 @@ function <> meta::relational::tests::mapping::extend::mainTable::test let superMappingMainTable = B2Mapping->classMappingById('b2')->cast(@RootRelationalInstanceSetImplementation)->map(x|$x->mainTable()); assertEquals($superMappingMainTable, $mainTable); } + + +function <> meta::relational::tests::mapping::extend::mainTable::testSuperSetIdsAreCollected():Any[*] +{ + let sets = meta::pure::mapping::allSuperSetImplementations( meta::relational::tests::mapping::extend::mainTable::C1Mapping->classMappingById('c1')->toOne()->cast(@PropertyMappingsImplementation),meta::relational::tests::mapping::extend::mainTable::C1Mapping); + assertSameElements(['a','b1'],$sets.id); + +} \ No newline at end of file