Skip to content

Commit

Permalink
support_for_multi_expressions_and_tds_joins_with_N_2_columns_support_…
Browse files Browse the repository at this point in the history
…for_multi_expressions.patch (#3141)
  • Loading branch information
AFine-gs authored Sep 30, 2024
1 parent fe0db0a commit 70f9f13
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 68 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 <<access.private>> 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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,28 @@ function meta::analytics::lineage::computeLineage(f:FunctionDefinition<Any>[1],
let modelToModelMappings = $mappings->init();

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

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

Expand Down
Loading

0 comments on commit 70f9f13

Please sign in to comment.