From c7df13ef090ce8fa1c48fa852cfbb14f50ac8cb5 Mon Sep 17 00:00:00 2001 From: AFine-gs <69924417+AFine-gs@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:45:41 -0400 Subject: [PATCH] Release4.58.0 fix source tree calculation for qualified property (#3150) Co-authored-by: Akash <109946032+siaka-Akash@users.noreply.github.com> --- .../sourceTreeCalc/testSourceTreeCalc.pure | 2 -- .../core/pure/lineage/scanProperties.pure | 17 ++++++++++------- .../modelCoverage/analyticsTest.pure | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/graphFetch/tests/sourceTreeCalc/testSourceTreeCalc.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/graphFetch/tests/sourceTreeCalc/testSourceTreeCalc.pure index 16f479bf82f..43dbf8863dd 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/graphFetch/tests/sourceTreeCalc/testSourceTreeCalc.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/graphFetch/tests/sourceTreeCalc/testSourceTreeCalc.pure @@ -2486,5 +2486,3 @@ Mapping meta::pure::graphFetch::tests::sourceTreeCalc::functionCaching::testMapp b: $src.c.b.d->func3($src.s2).val2 } ) - - 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 fc176eadc77..dc5c8e1cda6 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 @@ -85,15 +85,18 @@ function <> meta::pure::lineage::scanProperties::dummyNodeForCla ^PropertyPathNode( class = $c, property= getDummyProperty()); } -function <> meta::pure::lineage::scanProperties::findAndAddChildrenAtTheEnd(tree: PropertyPathTree[1], path: PropertyPathNode[*], toAdd: PropertyPathTree[*]):PropertyPathTree[1] +function meta::pure::lineage::scanProperties::findAndAddChildrenAtTheEnd(tree: PropertyPathTree[1], path: PropertyPathNode[*], toAdd: PropertyPathTree[*]):PropertyPathTree[1] { if($path->isEmpty(), | ^$tree(children += $toAdd), | let first = $path->at(0); - let correctTree = $tree.children->filter(x | $x.value->instanceOf(PropertyPathNode) && ($x.value->cast(@PropertyPathNode).property == $first.property))->toOne(); - let otherTrees = $tree.children->remove($correctTree); - ^$tree( - children = $otherTrees->concatenate($correctTree->findAndAddChildrenAtTheEnd($path->tail(), $toAdd)) + let correctTree = $tree.children->filter(x | $x.value->instanceOf(PropertyPathNode) && ($x.value->cast(@PropertyPathNode).property == $first.property)); + if($correctTree->isEmpty(), + |^$tree(children += $toAdd), + | let otherTrees = $tree.children->remove($correctTree->toOne()); + ^$tree( + children = $otherTrees->concatenate($correctTree->toOne()->findAndAddChildrenAtTheEnd($path->tail(), $toAdd)) + ); ); ) } @@ -788,8 +791,8 @@ function <> meta::pure::lineage::scanProperties::recurse_inlineQ {| let qual = $p.value->cast(@PropertyPathNode).property->cast(@QualifiedProperty); let qualifierTreeCurrent = $qual.expressionSequence->evaluateAndDeactivate()->toOne()->internal_scanProperties([], noVars(), $config,^Map(), noDebug()).current; - let qualifierTree = $p.qualifierSubTree.children->toOne(); - findAndAddChildrenAtTheEnd($qualifierTree, $qualifierTreeCurrent.values, $p.children).children; + let qualifierTree = $p.qualifierSubTree.children; + $qualifierTree->map(t | $t->findAndAddChildrenAtTheEnd($qualifierTreeCurrent.values, $p.children)).children; } )->map(nt| $nt->recurse_inlineQualifiedPropertyNodes($config)); }, diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/src/main/resources/core_analytics_mapping/modelCoverage/analyticsTest.pure b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/src/main/resources/core_analytics_mapping/modelCoverage/analyticsTest.pure index 5a1cc6275a3..25a5b473d37 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/src/main/resources/core_analytics_mapping/modelCoverage/analyticsTest.pure +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-mapping/legend-engine-xt-analytics-mapping-pure/src/main/resources/core_analytics_mapping/modelCoverage/analyticsTest.pure @@ -444,4 +444,4 @@ Mapping meta::analytics::mapping::modelCoverage::test::sampleModelToModelMapping ~src meta::analytics::mapping::modelCoverage::test::Street streetName: $src.streetName + '1' } -) +) \ No newline at end of file