diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/executionPlan/platformBinding/platformBinding.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/executionPlan/platformBinding/platformBinding.pure index 33cfa61ab29..d4d90780574 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/executionPlan/platformBinding/platformBinding.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/executionPlan/platformBinding/platformBinding.pure @@ -62,7 +62,7 @@ function meta::pure::executionPlan::platformBinding::extractPlatformBindingById( let platformBindings = $extensions.availablePlatformBindings->filter(p | $p.platformId == $platformId); assert($platformBindings->size() > 0, | 'Found no platform binding with id: ' + $platformId); let first = $platformBindings->at(0); - ^$first(platformBindingExtensions = $platformBindings.platformBindingExtensions->removeDuplicates(x|$x.id, {a,b|$a==$b})); + ^$first(platformBindingExtensions = $platformBindings.platformBindingExtensions->removeDuplicatesBy(x|$x.id)); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/extensions/functions.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/extensions/functions.pure index 082d0414e8a..39d1528acf3 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/extensions/functions.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/extensions/functions.pure @@ -35,7 +35,7 @@ import meta::pure::graphFetch::executionPlan::*; function meta::pure::extension::storeContractForSetImplementation(extensions: Extension[*], s:InstanceSetImplementation[1]):StoreContract[1] { $extensions.availableStores - ->removeDuplicates(x|$x.id,{a,b|$a==$b}) + ->removeDuplicatesBy(x|$x.id) ->filter(sc|$sc.supportsSetImplementation->eval($s)) ->unique(|'for the setImplementation ' + $s->class().name->toOne() + '. For the extensions: [' + $extensions.type->joinStrings(',') + ']'); } @@ -47,7 +47,7 @@ function meta::pure::extension::_storeContractForSetImplementation(extensions: E $extensions->meta::pure::extension::storeContractForSetImplementation($i->toOne()), o: meta::pure::mapping::OperationSetImplementation[1]| let roots = $o->resolveInstanceSetImplementations(); - $roots->map(r|$extensions->meta::pure::extension::storeContractForSetImplementation($r))->removeDuplicates(x|$x.id, {a,b|$a==$b})->toOne(); + $roots->map(r|$extensions->meta::pure::extension::storeContractForSetImplementation($r))->removeDuplicatesBy(x|$x.id)->toOne(); ] ); } @@ -55,14 +55,14 @@ function meta::pure::extension::_storeContractForSetImplementation(extensions: E function meta::pure::extension::storeContractFromStore(extensions: Extension[*], s: Store[1]):StoreContract[1] { $extensions.availableStores - ->removeDuplicates(x|$x.id,{a,b|$a==$b}) + ->removeDuplicatesBy(x|$x.id) ->filter(sc|$sc.supportsStore->eval($s)) ->unique(|'for the store ' + $s->class().name->toOne() + '. For the extensions: [' + $extensions.type->joinStrings(',') + ']'); } function <> meta::pure::extension::unique(storeContracts:StoreContract[*], message:Function<{->String[1]}>[1]):meta::pure::store::StoreContract[1] { - let list = $storeContracts->removeDuplicates(x|$x.id,{a,b|$a==$b}); + let list = $storeContracts->removeDuplicatesBy(x|$x.id); assert($list->isNotEmpty(), |'The system can\'t find the appropriate StoreContract '+$message->eval()); assert($list->size() == 1, |'The system found too many StoreContracts ['+$list.id->joinStrings(',')+'] '+$message->eval()); $list->toOne(); diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/builder.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/builder.pure index 475df3c0aa9..94b8f4e61c0 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/builder.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/builder.pure @@ -301,7 +301,7 @@ function <> meta::pure::router::store::routing::permutationSetOn function meta::pure::router::store::routing::permute(var:PermutationSet[*]):List[*] { - let l = $var->map(p|^List(values=$p.sets->removeDuplicates({a,b|$a.id == $b.id})->map(v|^$p(sets=$v)))); + let l = $var->map(p|^List(values=$p.sets->removeDuplicatesBy(x|$x.id)->map(v|^$p(sets=$v)))); let seed = $l->head().values->map(o|^List(values=$o)); $l->tail()->fold({v,a|$a->combine($v.values)}, $seed); } @@ -333,8 +333,8 @@ function <> meta::pure::router::store::routing::unionL(vs:Functi let fr = $vs->at(0); let i = $fr.value->cast(@InstanceValue); let l = $i.values->at(0)->cast(@LambdaFunction); - let res = $vs.value->cast(@InstanceValue).values->cast(@LambdaFunction).expressionSequence->map(e|pair($e->asString(), $e))->removeDuplicates({a,b|$a.first == $b.first}); - ^$fr(value=^$i(values=^$l(expressionSequence=doUnion($res.second, $concatenate, $l.expressionSequence->toOne().genericType)))); + let res = $vs.value->cast(@InstanceValue).values->cast(@LambdaFunction).expressionSequence->removeDuplicatesBy(e|$e->asString()); + ^$fr(value=^$i(values=^$l(expressionSequence=doUnion($res, $concatenate, $l.expressionSequence->toOne().genericType)))); } function <> meta::pure::router::store::routing::doUnion(v:ValueSpecification[*], concatenate:Boolean[1], genericType:GenericType[1]):ValueSpecification[1] diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/cluster.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/cluster.pure index e9a73494cc8..38398a86bfa 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/cluster.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/store/cluster.pure @@ -486,8 +486,8 @@ function meta::pure::router::clustering::storeContractForSetImplementation(setIm pair($storeContract, $mapping->resolveStore($store));, o: meta::pure::mapping::OperationSetImplementation[1]| let roots = $o->resolveInstanceSetImplementations(); - let storeContract = $roots->map(r|$extensions->meta::pure::extension::storeContractForSetImplementation($r))->removeDuplicates(x|$x.id,{a,b|$a==$b})->toOne(); - let store = $roots->map(r|$mapping->resolveStore($storeContract.resolveStoreFromSetImplementation->toOne()->eval($r)))->removeDuplicates(x|$x->elementToPath(),{a,b|$a==$b})->toOne(); + let storeContract = $roots->map(r|$extensions->meta::pure::extension::storeContractForSetImplementation($r))->removeDuplicatesBy(x|$x.id)->toOne(); + let store = $roots->map(r|$mapping->resolveStore($storeContract.resolveStoreFromSetImplementation->toOne()->eval($r)))->removeDuplicatesBy(x|$x->elementToPath())->toOne(); pair($storeContract, $mapping->resolveStore($store)); ]); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/tds/tds.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/tds/tds.pure index 52c656f16d4..e72ec006ef3 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/tds/tds.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/tds/tds.pure @@ -872,4 +872,4 @@ function meta::pure::tds::groupByWithWindowSubset(set:K[*], functions:met meta::pure::tds::groupBy( $set, $subSetfunctions ,$newAggValues , $newIds ); -} \ No newline at end of file +} diff --git a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/flow.pure b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/flow.pure index 8d7e967f65f..a28b65177ee 100644 --- a/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/flow.pure +++ b/legend-engine-xts-analytics/legend-engine-xts-analytics-lineage/legend-engine-xt-analytics-lineage-pure/src/main/resources/core_analytics_lineage/flow.pure @@ -132,7 +132,7 @@ function meta::analytics::lineage::flow::merge(flows:Flow[*]):Flow[1] functions = $flows.functions->removeDuplicates(), databases = $flows.databases->removeDuplicates(), tables = $flows.tables->removeDuplicates(), - systems = $flows.systems->removeDuplicates({a,b|$a.appId == $b.appId}), + systems = $flows.systems->removeDuplicatesBy(a | $a.appId), packages = $flows.packages->removeDuplicates(), classes = $flows.classes->removeDuplicates(), properties = $flows.properties->removeDuplicates(), diff --git a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/src/main/resources/core_elasticsearch_seven_metamodel/executionPlan/executionPlan_generation.pure b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/src/main/resources/core_elasticsearch_seven_metamodel/executionPlan/executionPlan_generation.pure index 71b685492bb..7559146db3d 100644 --- a/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/src/main/resources/core_elasticsearch_seven_metamodel/executionPlan/executionPlan_generation.pure +++ b/legend-engine-xts-elasticsearch/legend-engine-xt-elasticsearch-V7-pure-metamodel/src/main/resources/core_elasticsearch_seven_metamodel/executionPlan/executionPlan_generation.pure @@ -43,6 +43,6 @@ function meta::external::store::elasticsearch::v7::executionPlan::generation::pl if ($processOutput.extraNodes->isEmpty(), |$esNode, - |^SequenceExecutionNode(resultType = $esNode.resultType, executionNodes = $processOutput.extraNodes->removeDuplicates({x, y | $x.varName == $y.varName})->concatenate($esNode)) + |^SequenceExecutionNode(resultType = $esNode.resultType, executionNodes = $processOutput.extraNodes->removeDuplicatesBy(x | $x.varName)->concatenate($esNode)) ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-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/src/main/resources/core_relational/relational/lineage/scanColumns/scanColumns.pure index 4b5a2d6eba1..2ccbf1568ee 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-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/src/main/resources/core_relational/relational/lineage/scanColumns/scanColumns.pure @@ -96,7 +96,7 @@ function <> meta::pure::lineage::scanColumns::scanColumns(p:Prop | let nClassToSets = if($classToSets->keys()->contains($cl), |$classToSets, | $classToSets->keyValues()->concatenate(pair($cl, list($m->_classMappingByClass($cl)->map(s|$s->resolveOperation($m)))))->newMap()); let nsets = $nClassToSets->get($cl).values; - $p.children->map(c|$c->scanColumns($m, $sets->concatenate($nsets)->removeDuplicates({a,b|$a.id == $b.id}), $nClassToSets, $idToSet, false, ^$debug(space=$debug.space+' ')));, + $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, $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/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 3947cf15024..b5d0268fe83 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 @@ -187,7 +187,7 @@ function <> meta::pure::lineage::scanRelations::scanRelations(p: | [], | if($source->isNotEmpty(), | $source, - | $m->rootClassMappingByClass($cl)->toOne()->resolveOperation($m)->removeDuplicates({a,b|$a.id == $b.id})->filter(s | $s->instanceOf(RootRelationalInstanceSetImplementation))->cast(@RootRelationalInstanceSetImplementation); + | $m->rootClassMappingByClass($cl)->toOne()->resolveOperation($m)->removeDuplicatesBy(x | $x.id)->filter(s | $s->instanceOf(RootRelationalInstanceSetImplementation))->cast(@RootRelationalInstanceSetImplementation); ); ); print(if($debug.debug,|$debug.space+'Process Class: '+$cl.name->toOne()+', Sets: '+$finalSources.id->joinStrings('[',',',']')+'\n',|'')); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure index c3651ec0998..615e7a5c4c2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/pureToSQLQuery.pure @@ -320,7 +320,7 @@ function meta::relational::functions::pureToSqlQuery::pushExtraFilteringOperatio |$s, |^$s( extraFilteringOperation = [], - filteringOperation=$s.filteringOperation->concatenate($s.extraFilteringOperation->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second)->andFilters($extensions) + filteringOperation=$s.filteringOperation->concatenate($s.extraFilteringOperation->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions)))->andFilters($extensions) ) ); } @@ -343,7 +343,7 @@ function meta::relational::functions::pureToSqlQuery::orderImmediateChildNodeByJ function meta::relational::functions::pureToSqlQuery::combineFilters(s:RelationalOperationElement[*], and:Boolean[1], extensions:Extension[*]):RelationalOperationElement[0..1] { - let ns = $s->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second; + let ns = $s->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions)); if ($ns->isEmpty(), |[], |if ($ns->size() == 1, @@ -1101,7 +1101,7 @@ function meta::relational::functions::pureToSqlQuery::buildCorrelatedSubQuery(se // Find the columns that are in the filter but refer to nodes outside of the correlated subQuery let foundNodeSubNodes = $child->getAllNodes()->cast(@JoinTreeNode).alias; - let filters = if($select.savedFilteringOperation->isEmpty(),|[],|$select.savedFilteringOperation.second->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second); + let filters = if($select.savedFilteringOperation->isEmpty(),|[],|$select.savedFilteringOperation.second->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions))); let filtersPartition = $filters->map(f|let condition = $f->extractTableAliasColumns()->filter(t|!$foundNodeSubNodes.name->contains($t.alias.name))->isEmpty(); if($condition,|^BiContainer(first=$f),|^BiContainer(second=$f)); ); @@ -1703,7 +1703,7 @@ function meta::relational::functions::pureToSqlQuery::processRelationalPropertyM ), |^$secondStep(select = ^$newSel(savedFilteringOperation = $newSel.savedFilteringOperation ->concatenate(pair($sel.leftSideOfFilter->toOne(), $srcOperation.select.filteringOperation->toOne())) - ->map(f|pair($f.second->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second + ->removeDuplicatesBy(f|$f.second->buildUniqueName(true, $extensions)) ) ) ); @@ -1804,7 +1804,7 @@ function meta::relational::functions::pureToSqlQuery::processRelationalPropertyM | //firstStep can result in (saved) milestoning filtering operations which need to be processed along with the existing src saved filtering operations let savedFilteringOpWithOldAndNewOps=$newSel.savedFilteringOperation->map(p| let existingOrNewNode=if($oldSrcOperation.select.savedFilteringOperation->contains($p),|$p.first->findOneNode($oldSrcOperation.select.data->toOne(), $newSel.data->toOne()),|$p.first);pair($existingOrNewNode, $p.second);) ->concatenate(pair($newSel.leftSideOfFilter->toOne(), $oldSrcOperation.select.filteringOperation->toOne())) - ->map(f|pair($f.second->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second; + ->removeDuplicatesBy(f|$f.second->buildUniqueName(true, $extensions)); ^$firstStep(select = ^$newSel(savedFilteringOperation = $savedFilteringOpWithOldAndNewOps)); ); @@ -1918,7 +1918,7 @@ function meta::relational::functions::pureToSqlQuery::processCrossPropertyMappin | //firstStep can result in (saved) milestoning filtering operations which need to be processed along with the existing src saved filtering operations let savedFilteringOpWithOldAndNewOps=$newSel.savedFilteringOperation->map(p| let existingOrNewNode=if($oldSrcOperation.select.savedFilteringOperation->contains($p),|$p.first->findOneNode($oldSrcOperation.select.data->toOne(), $newSel.data->toOne()),|$p.first);pair($existingOrNewNode, $p.second);) ->concatenate(pair($newSel.leftSideOfFilter->toOne(), $oldSrcOperation.select.filteringOperation->toOne())) - ->map(f|pair($f.second->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second; + ->removeDuplicatesBy(f|$f.second->buildUniqueName(true, $extensions)); ^$firstStep(select = ^$newSel(savedFilteringOperation = $savedFilteringOpWithOldAndNewOps)); ); @@ -2097,7 +2097,7 @@ function meta::relational::functions::pureToSqlQuery::processConcatenate(f:Funct let newSelect = if ($select.extraFilteringOperation->isEmpty(), |$select, |^$select(extraFilteringOperation=[], - filteringOperation=$select.filteringOperation->concatenate($select.extraFilteringOperation->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second)->andFilters($extensions) + filteringOperation=$select.filteringOperation->concatenate($select.extraFilteringOperation->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions)))->andFilters($extensions) ) ); let newSelectWithCursor = ^$selectWithCursor(select = $newSelect); @@ -2225,7 +2225,7 @@ function meta::relational::functions::pureToSqlQuery::processConcatenate(f:Funct let firstJoin = $newJoins->at(0); let firstChild = $newSelectsWithCutNode->at(0).first; - let joinY = ^$firstJoin(operation = $newJoins->removeDuplicates({a,b|$a.name == $b.name}).operation->orFilters($extensions)->cast(@Operation)->toOne()); + let joinY = ^$firstJoin(operation = $newJoins->removeDuplicatesBy(x | $x.name).operation->orFilters($extensions)->cast(@Operation)->toOne()); let newChild = ^$firstChild(alias=$unionNode, join=$joinY, childrenData=[]); let sel = $operation.select; @@ -2278,15 +2278,14 @@ function meta::relational::functions::pureToSqlQuery::buildConcatenateSubSelect( ->map(t:TableAliasColumn[1]|^Alias(name=$t.column.name, relationalElement=$t))) ->removeDuplicates(), filteringOperation = if($isDataType,|[],|$leftSelect.filteringOperation)->concatenate($leftSelect.savedFilteringOperation.second) - ->map(f|pair($f->buildUniqueName(false, $extensions), $f)) - ->removeDuplicates({a,b|$a.first == $b.first}) - .second->andFilters($extensions) + ->removeDuplicatesBy(f|$f->buildUniqueName(false, $extensions)) + ->andFilters($extensions) ); } function <> meta::relational::functions::pureToSqlQuery::alignJoinAndPkColumnsForUnion(select: SelectSQLQuery[1], allColumns:RelationalOperationElement[*]):SelectSQLQuery[1] { - let allCols = $allColumns->removeDuplicates({a,b|$a->cast(@Alias).name == $b->cast(@Alias).name})->cast(@Alias).name; + let allCols = $allColumns->map(c | $c->cast(@Alias).name)->removeDuplicates(); let sqlNull = ^Literal(value=^SQLNull()); let newCols = $allCols->map(a| let col = $select.columns->filter(c|$c->cast(@Alias).name == $a); @@ -4202,7 +4201,7 @@ function meta::relational::functions::pureToSqlQuery::buildExistsAsJoinWithNullC let joinAndNonJoinElements = $existsFilter.groupBy->partition(r| let tacs = $r->extractTableAliasColumns(); $tacs->size() == 1 && $joinAliases->contains($tacs->at(0)); ); - let allColumns = $joinAliases->concatenate($existsFilter.groupBy)->removeDuplicates({a,b| $a == $b }); + let allColumns = $joinAliases->concatenate($existsFilter.groupBy)->removeDuplicates(); assertFalse($joinAliases->isEmpty(),'Cant find any aliases right side of exists ->'); @@ -5801,7 +5800,7 @@ function meta::relational::functions::pureToSqlQuery::processProject(ids:String[ ^$operation( select = ^TdsSelectSqlQuery( distinct = $merge.distinct, - columns = $nonOlap->concatenate($importDataFlowCols)->cast(@Alias)->removeDuplicates({a,b|$a.name == $b.name})->concatenate($olapCols), + columns = $nonOlap->concatenate($importDataFlowCols)->cast(@Alias)->removeDuplicatesBy(a|$a.name)->concatenate($olapCols), data = $possiblePKsWithUpdatedData.second, savedFilteringOperation = $merge.savedFilteringOperation, filteringOperation = $merge.filteringOperation, @@ -6353,7 +6352,7 @@ function meta::relational::functions::pureToSqlQuery::moveSelectQueryToSubSelect relationalElement=^$select( data = $newData, filteringOperation = $reprocessedFilteringOperation, - columns = $reprocessedColumns.second->cast(@Alias)->removeDuplicates({a,b|$a.name == $b.name}), + columns = $reprocessedColumns.second->cast(@Alias)->removeDuplicatesBy(a|$a.name), preIsolationCurrentTreeNode = $currentTreeNode, groupBy = $reprocessedGroupBys->filter(c|$c->instanceOf(TableAliasColumn)), leftSideOfFilter = $newLeftSideOfFilter @@ -6853,7 +6852,7 @@ function meta::relational::functions::pureToSqlQuery::possiblyMergeUnions(common let newQueries = $union.queries->zip($otherUnion.queries)->map(q|let f = $q.first; let s = $q.second; let merged = [$f, $s]->mergeSQLQueryData($nodeId, $state, $context, $extensions); - ^$merged(filteringOperation = $merged.filteringOperation->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second); + ^$merged(filteringOperation = $merged.filteringOperation->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions))); ); let merged = ^$union(queries = $newQueries, @@ -6938,7 +6937,7 @@ function meta::relational::functions::pureToSqlQuery::merge(parentTargetTreeNode let initAlias = ^OldAliasToNewAlias(first=$sourceTreeNode.alias.name, second=$a.node.alias); let res = reprocessJoinTreeNode($sourceTreeNode, $childNode, $initAlias, $nodeId); let newAliases = $res.second.values->add($initAlias); - let parentFilters = $a.filteringOperation->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second; + let parentFilters = $a.filteringOperation->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions)); let parentSavedFilters = $a.savedFilteringOperation; let parentExtraFilters = $a.extraFilteringOperation; let parentGroupBy = $a.groupBy; @@ -6998,7 +6997,7 @@ function meta::relational::functions::pureToSqlQuery::merge(parentTargetTreeNode let mergedOriginalNode = $a.node->possiblyMergeUnions($sourceTreeNode, $nodeId, $state, $context, $extensions); - let parentFilters = $mergeNodes.filteringOperation->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second; + let parentFilters = $mergeNodes.filteringOperation->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions)); let parentSavedFilters = $mergeNodes.savedFilteringOperation; let parentExtraFiler = $mergeNodes.extraFilteringOperation; let parentGroupBy = $mergeNodes.groupBy; @@ -7123,11 +7122,11 @@ function meta::relational::functions::pureToSqlQuery::mergeSQLQueryData(preQuery let filtered = ^$res ( leftSideOfFilter = if($querySet->at(0).leftSideOfFilter->isEmpty(),|[],|$querySet->at(0).leftSideOfFilter->toOne()->findOneNode($querySet->at(0).data->toOne(), $res.data->toOne())), - savedFilteringOperation = $res.savedFilteringOperation->map(f|pair($f.second->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second + savedFilteringOperation = $res.savedFilteringOperation->removeDuplicatesBy(f|$f.second->buildUniqueName(true, $extensions)) ->map(p| let originalQuery = $querySet->filter(q|!$q.data->isEmpty() && $q.data->toOne()->getAllNodes()->contains($p.first)); pair(if ($originalQuery->isEmpty(),|$p.first,|$p.first->findOneNode($originalQuery->at(0).data->toOne(), $res.data->toOne())), $p.second); ), - extraFilteringOperation = $res.extraFilteringOperation->map(f|pair($f->buildUniqueName(true, $extensions), $f))->removeDuplicates({a,b|$a.first == $b.first}).second + extraFilteringOperation = $res.extraFilteringOperation->removeDuplicatesBy(f|$f->buildUniqueName(true, $extensions)) ); diff --git a/legend-engine-xts-xml/legend-engine-xt-xml-pure/src/main/resources/core_external_format_xml/transformation/toPure/xsdToPure.pure b/legend-engine-xts-xml/legend-engine-xt-xml-pure/src/main/resources/core_external_format_xml/transformation/toPure/xsdToPure.pure index 9e0ac6451e6..b7aea7bf08b 100644 --- a/legend-engine-xts-xml/legend-engine-xt-xml-pure/src/main/resources/core_external_format_xml/transformation/toPure/xsdToPure.pure +++ b/legend-engine-xts-xml/legend-engine-xt-xml-pure/src/main/resources/core_external_format_xml/transformation/toPure/xsdToPure.pure @@ -435,7 +435,7 @@ function <> meta::external::format::xml::transformation::toPure: { $debug->log(|'--- Inlining Collection Classes'); - let classInfos = $context.genInfos->values()->map(i| $i->findClasses())->removeDuplicates({c1,c2| $c1.name == $c2.name}); + let classInfos = $context.genInfos->values()->map(i| $i->findClasses())->removeDuplicatesBy(c | $c.name); let inlineable = $classInfos->filter({ci| $debug->log(|' Examining class (pass 1) ' + $ci.name->qNameToString()); let props = $ci.properties; @@ -577,7 +577,7 @@ function <> meta::external::format::xml::transformation::toPure: pair($ei, $enum); })->newMap(); - let classInfos = $context.genInfos->values()->map(i| $i->findClasses())->removeDuplicates({c1,c2| $c1.name == $c2.name}); + let classInfos = $context.genInfos->values()->map(i| $i->findClasses())->removeDuplicatesBy(c | $c.name); let classNames = $classInfos->map(ci| $context->typeName($ci.rawName)); assert($classNames->isDistinct(), | 'Class names are not unique: ' + $classNames->joinStrings(',')); @@ -2001,4 +2001,3 @@ function <> meta::external::format::xml::transformation::toPure: { $factory->func(or_Boolean_1__Boolean_1__Boolean_1_, [$arg1, $arg2]); } -