Skip to content

Commit

Permalink
Revert "support for multi expressions and tds joins with N>2 columns (#…
Browse files Browse the repository at this point in the history
…3134)" (#3135)

This reverts commit db6f925.
  • Loading branch information
AFine-gs authored Sep 27, 2024
1 parent b8bbcc7 commit 920375c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function <<access.private>> 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 <<access.private>> meta::pure::lineage::scanProperties::findAndAddChildrenAtTheEnd(tree: PropertyPathTree[1], path: PropertyPathNode[*], toAdd: PropertyPathTree[*]):PropertyPathTree[1]
{
if($path->isEmpty(),
| ^$tree(children += $toAdd),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,27 @@ function meta::analytics::lineage::computeLineage(f:FunctionDefinition<Any>[1],
let modelToModelMappings = $mappings->init();

let sourceMapping = $mappings->last()->toOne();
let funcBody = $f.expressionSequence->evaluateAndDeactivate();
let updatedFuncBody = $funcBody->map(e|$e->meta::pure::lineage::analytics::inlineQualifiedProperties(newMap([]->cast(@Pair<VariableExpression, ValueSpecification>), VariableExpression->classPropertyByName('name')->cast(@Property<VariableExpression,String|1>)), $f->openVariableValues(), $extensions));
let propertyTrees = $updatedFuncBody->map(e|$e->buildMultiLevelPropertyTrees($modelToModelMappings, $extensions));

let combinedTrees = if( $propertyTrees->size()>1,|$propertyTrees->first()->toOne()->findAndAddChildrenAtTheEnd([],$propertyTrees->tail()),|$propertyTrees->toOne());
let funcBody = $f.expressionSequence->at(0)->evaluateAndDeactivate();
let updatedFuncBody = $funcBody->meta::pure::lineage::analytics::inlineQualifiedProperties(newMap([]->cast(@Pair<VariableExpression, ValueSpecification>), VariableExpression->classPropertyByName('name')->cast(@Property<VariableExpression,String|1>)), $f->openVariableValues(), $extensions);
let propertyTrees = $updatedFuncBody->buildMultiLevelPropertyTrees($modelToModelMappings, $extensions);

let reprocessedFuncBody = if($modelToModelMappings->isEmpty() && $mappings->size() == 1,
|$updatedFuncBody,
|$updatedFuncBody->map(e|$e->cast(@FunctionExpression)->meta::pure::mapping::modelToModel::chain::allReprocess([], $modelToModelMappings, $extensions, noDebug()).res));
|$updatedFuncBody->cast(@FunctionExpression)->meta::pure::mapping::modelToModel::chain::allReprocess([], $modelToModelMappings, $extensions, noDebug()).res);

let vars = $f->functionType().parameters->evaluateAndDeactivate()->map(p| pair($p.name, ^List<PlanVarPlaceHolder>(values = ^PlanVarPlaceHolder(name=$p.name, type = $p.genericType.rawType->toOne(), multiplicity=$p.multiplicity))));
let relationTree = if($f->functionReturnType().rawType->toOne()->_subTypeOf(TabularDataSet) && $r->isNotEmpty() && $modelToModelMappings->isEmpty(),
| scanRelations(^LambdaFunction<{->Any[*]}>(expressionSequence = $funcBody), $sourceMapping, $r->toOne(), $vars, noDebug(), $extensions),
| scanRelations($combinedTrees->last()->toOne(), $sourceMapping));
| scanRelations($propertyTrees->last()->toOne(), $sourceMapping));

let classLineageMapping = if($modelToModelMappings->isEmpty() && $mappings->size() == 1, | $sourceMapping, | $modelToModelMappings);
^FunctionAnalytics
(
databaseLineage = $f->toFlowDatabase($sourceMapping, $combinedTrees, $r)->toGraph(),
classLineage = $f->toFlowClass($combinedTrees, $classLineageMapping)->toGraph(),
functionTrees = $combinedTrees,
databaseLineage = $f->toFlowDatabase($sourceMapping, $propertyTrees->last()->toOne(), $r)->toGraph(),
classLineage = $f->toFlowClass($propertyTrees->at(0), $classLineageMapping)->toGraph(),
functionTrees = $propertyTrees,
relationTree = $relationTree,
reportLineage = buildReportLineage($reprocessedFuncBody->last()->toOne(), $sourceMapping)
reportLineage = buildReportLineage($reprocessedFuncBody, $sourceMapping)
);
}

Expand Down Expand Up @@ -148,7 +147,6 @@ Class meta::analytics::lineage::Column
function meta::analytics::lineage::buildReportLineage(funcBody:ValueSpecification[1], mapping:Mapping[1]):ReportLineage[1]
{
let project = $funcBody->meta::pure::lineage::scanProject::scanProject();

let groupedProject = $project.columns->groupBy(c| $c.first);

let colPropertyTreePair = $groupedProject->keys()->map(gp|let propertiesPaths = $groupedProject->get($gp).values->map(c| $c.second.expressionSequence->at(0)->scanProperties(^List<PropertyPathNode>(), [], [], noDebug()))->removeDuplicates();
Expand Down
Loading

0 comments on commit 920375c

Please sign in to comment.