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 c27d8139bbf..b6c38f5678c 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 @@ -125,3 +125,16 @@ function <> meta::analytics::lineage::tests::re } + +###Pure +import meta::analytics::lineage::*; +import meta::relational::tests::*; +import meta::relational::tests::model::simple::*; +function <> meta::analytics::lineage::tests::relational::testProjectWithIsolatedFilterMultiJoinTrees():Boolean[1] +{ + let fn = { |Order.all()-> filter( p| $p.pnlContact->exists(l|$l.address.name == 'Main St' && $l.firm.legalName == 'Co' )) + ->project([ f|$f.quantity ], ['quantity'])}; + let lineage = computeLineage($fn,simpleRelationalMapping, meta::external::store::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); + assertSameElements(['Lambda', 'db_db', 'db_dbInc', 'tb_dbIncdefaultaddressTable', 'tb_dbIncdefaultfirmTable', 'tb_dbIncdefaultpersonTable', 'tb_dbdefaultaccountTable', 'tb_dbdefaultorderPnlTable', 'tb_dbdefaultorderTable', 'tb_dbdefaultsalesPersonTable'],$lineage.databaseLineage.nodes.data.id); + +} \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-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/src/main/resources/core_relational/relational/lineage/scanRelations/scanRelations.pure index 41be682e587..105d83cb5fe 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-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/src/main/resources/core_relational/relational/lineage/scanRelations/scanRelations.pure @@ -725,12 +725,18 @@ function <> meta::pure::lineage::scanRelations::extractSourceCol if($reqTableAliasColumn->isEmpty() || $select.data->isEmpty(), |[], |let rootTree = $select.data->toOne(); - let childTrees = $rootTree->children()->map(child | $child->extractLine()); + let childTrees = $rootTree->children()->map(child | $child->extractJoinChildren()); let sourceOperation = $rootTree->concatenate($childTrees)->filter(tree | $tree.alias.name == $reqTableAliasColumn.alias.name).alias->toOne(); $reqTableAliasColumn->toOne()->extractSourceColumn($sourceOperation, $relationIdentifiers, $sourceTree); ); } +function <> meta::pure::lineage::scanRelations::extractJoinChildren(j:JoinTreeNode[1]):JoinTreeNode[*] +{ + $j->concatenate(if($j->children()->isEmpty(),|[],|$j->children()->map(c|$c->extractJoinChildren()))); +} + + function <> meta::pure::lineage::scanRelations::extractSourceRelation(sourceOperation:RelationalOperationElement[1], relationIdentifiers:String[*]):NamedRelation[1] { $sourceOperation->match([