From 72c4f10fa17bcf96e7a9b2e368bc879959f92aee Mon Sep 17 00:00:00 2001 From: Pierre De Belen Date: Wed, 21 Aug 2024 18:02:29 -0400 Subject: [PATCH] Fix build issues (#3030) --- .../pure/serialization/toPureGrammar.pure | 8 +++++- .../pureToSQLQuery/pureToSQLQuery.pure | 26 +++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure index 4b2088a8711..8425f68bdf4 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/serialization/toPureGrammar.pure @@ -130,7 +130,13 @@ function meta::pure::metamodel::serialization::grammar::printFunctionExpression( if($functionExpression.parametersValues->isEmpty(), |$name->toOne()+'()', |if ($name == 'getAll', - |$functionExpression.parametersValues->at(0)->cast(@InstanceValue).genericType.rawType->toOne()->cast(@Class)->elementToPath() + '.all()';, + |let genericType = $functionExpression.parametersValues->at(0)->cast(@InstanceValue).genericType; + let main = $genericType.rawType->toOne()->cast(@Class); + let val = if ($main == Class, + |$genericType.typeArguments->at(0).rawType->toOne()->cast(@Class), + |$main + ); + $val->elementToPath() + '.all()';, |let m = special(); if ($m->get($name)->isEmpty(), | let firstParam = $functionExpression.parametersValues->head()->toOne(); 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 79a558aa0f1..6136f9beff1 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 @@ -2793,7 +2793,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWindowColWithout let sortInfo = $f.parametersValues->at(1)->cast(@ValueSpecification)->map(v|$v->reprocessVS()->reactivate($state.inScopeVars)->cast(@SortInformation)); let newColumnName = $f.parametersValues->last()->cast(@InstanceValue).values->at(0)->extractName(); let topQuery = processValueSpecification($f.parametersValues->at(0), $currentPropertyMapping, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->toOne()->cast(@SelectWithCursor); - processTdsWindowColumn(false,$f, [], $sortInfo, $newColumnName,$f.parametersValues->at(2)->cast(@ValueSpecification)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); + processTdsWindowColumn(false,$f, [], $sortInfo, $newColumnName,$f.parametersValues->at(2)->cast(@ValueSpecification)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); } function meta::relational::functions::pureToSqlQuery::processTdsWindowColWithoutSort(f:FunctionExpression[1], currentPropertyMapping:PropertyMapping[*], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] @@ -2801,14 +2801,14 @@ function meta::relational::functions::pureToSqlQuery::processTdsWindowColWithout let partitionKeys = $f.parametersValues->at(1)->cast(@InstanceValue).values->map(x|$x->toString()); let newColumnName = $f.parametersValues->last()->cast(@InstanceValue).values->at(0)->extractName(); let topQuery = processValueSpecification($f.parametersValues->at(0), $currentPropertyMapping, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->toOne()->cast(@SelectWithCursor); - processTdsWindowColumn(false, $f, $partitionKeys, [], $newColumnName,$f.parametersValues->at(2)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); + processTdsWindowColumn(false, $f, $partitionKeys, [], $newColumnName,$f.parametersValues->at(2)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); } function meta::relational::functions::pureToSqlQuery::processTdsWindowColWithoutWindowAndSort(f:FunctionExpression[1], currentPropertyMapping:PropertyMapping[*], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] { let newColumnName = $f.parametersValues->last()->cast(@InstanceValue).values->at(0)->extractName(); let topQuery = processValueSpecification($f.parametersValues->at(0), $currentPropertyMapping, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->toOne()->cast(@SelectWithCursor); - processTdsWindowColumn(false, $f, [], [], $newColumnName ,$f.parametersValues->at(1)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); + processTdsWindowColumn(false, $f, [], [], $newColumnName ,$f.parametersValues->at(1)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); } function meta::relational::functions::pureToSqlQuery::processTdsWindowColumn(f:FunctionExpression[1], currentPropertyMapping:PropertyMapping[*], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] @@ -2817,14 +2817,14 @@ function meta::relational::functions::pureToSqlQuery::processTdsWindowColumn(f:F let sortInfo = $f.parametersValues->at(2)->cast(@ValueSpecification)->map(v|$v->reprocessVS()->reactivate($state.inScopeVars)->cast(@SortInformation)); let newColumnName = $f.parametersValues->last()->cast(@InstanceValue).values->at(0)->extractName(); let topQuery = processValueSpecification($f.parametersValues->at(0), $currentPropertyMapping, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->toOne()->cast(@SelectWithCursor); - processTdsWindowColumn(false,$f, $partitionKeys, $sortInfo, $newColumnName, $f.parametersValues->at(3)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); + processTdsWindowColumn(false,$f, $partitionKeys, $sortInfo, $newColumnName, $f.parametersValues->at(3)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); } function meta::relational::functions::pureToSqlQuery::processTdsAggColSpec(f:FunctionExpression[1], currentPropertyMapping:PropertyMapping[*], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] { let newColumnName = $f.parametersValues->last()->cast(@InstanceValue).values->at(0)->extractName(); let topQuery = processValueSpecification($f.parametersValues->at(0), $currentPropertyMapping, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->toOne()->cast(@SelectWithCursor); - processTdsWindowColumn(true, $f, [], [], $newColumnName, $f.parametersValues->at(1)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(),$currentPropertyMapping, $topQuery, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); + processTdsWindowColumn(true, $f, [], [], $newColumnName, $f.parametersValues->at(1)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(),$currentPropertyMapping, $topQuery, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); } function meta::relational::functions::pureToSqlQuery::processTdsAggColSpecArray(f:FunctionExpression[1], currentPropertyMapping:PropertyMapping[*], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] @@ -2833,7 +2833,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsAggColSpecArray( let aggColSpec = $f.parametersValues->at(1)->cast(@InstanceValue).values->at(0)->cast(@meta::pure::metamodel::relation::AggColSpecArray); $aggColSpec.aggSpecs->fold({aggSpec,a| let newColumnName = $aggSpec->extractName(); - processTdsWindowColumn(true, $f, [], [], $newColumnName, $aggSpec, $currentPropertyMapping, $a, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->cast(@SelectWithCursor); + processTdsWindowColumn(true, $f, [], [], $newColumnName, $aggSpec, $currentPropertyMapping, $a, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->cast(@SelectWithCursor); }, $topQuery); } @@ -2844,7 +2844,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWinAggColSpec(f: let sortInfo = $window.sortInfo->map(s | ^SortInformation(column = $s.column.name, direction = if($s.direction == SortType.ASC, |meta::pure::tds::SortDirection.ASC,|meta::pure::tds::SortDirection.DESC))); let newColumnName = $f.parametersValues->last()->cast(@InstanceValue).values->at(0)->extractName(); let topQuery = processValueSpecification($f.parametersValues->at(0), $currentPropertyMapping, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->toOne()->cast(@SelectWithCursor); - processTdsWindowColumn(true, $f,$partitionKeys,$sortInfo, $newColumnName, $f.parametersValues->at(2)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); + processTdsWindowColumn(true, $f,$partitionKeys,$sortInfo, $newColumnName, $f.parametersValues->at(2)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); } function meta::relational::functions::pureToSqlQuery::processTdsWinAggColSpecArray(f:FunctionExpression[1], currentPropertyMapping:PropertyMapping[*], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] @@ -2857,7 +2857,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWinAggColSpecArr $aggColSpec.aggSpecs->fold({aggSpec,a| let newColumnName = $aggSpec->extractName(); - processTdsWindowColumn(true, $f, $partitionKeys, $sortInfo, $newColumnName, $aggSpec, $currentPropertyMapping, $a, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->cast(@SelectWithCursor); + processTdsWindowColumn(true, $f, $partitionKeys, $sortInfo, $newColumnName, $aggSpec, $currentPropertyMapping, $a, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->cast(@SelectWithCursor); }, $topQuery); } @@ -2868,7 +2868,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWinFuncColSpec(f let sortInfo = $window.sortInfo->map(s | ^SortInformation(column = $s.column.name, direction = if($s.direction == SortType.ASC, |meta::pure::tds::SortDirection.ASC,|meta::pure::tds::SortDirection.DESC))); let newColumnName = $f.parametersValues->last()->cast(@InstanceValue).values->at(0)->extractName(); let topQuery = processValueSpecification($f.parametersValues->at(0), $currentPropertyMapping, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->toOne()->cast(@SelectWithCursor); - processTdsWindowColumn(true, $f,$partitionKeys,$sortInfo, $newColumnName,$f.parametersValues->at(2)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); + processTdsWindowColumn(true, $f,$partitionKeys,$sortInfo, $newColumnName,$f.parametersValues->at(2)->cast(@ValueSpecification)->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate()->toOne(), $currentPropertyMapping, $topQuery, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions); } function meta::relational::functions::pureToSqlQuery::processTdsWinFuncColSpecArray(f:FunctionExpression[1], currentPropertyMapping:PropertyMapping[*], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] @@ -2881,7 +2881,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWinFuncColSpecAr $funcColSpec.funcSpecs->fold({funcSpec,a| let newColumnName = $funcSpec->extractName(); - processTdsWindowColumn(true, $f, $partitionKeys, $sortInfo, $newColumnName, $funcSpec, $currentPropertyMapping, $a, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->cast(@SelectWithCursor); + processTdsWindowColumn(true, $f, $partitionKeys, $sortInfo, $newColumnName, $funcSpec, $currentPropertyMapping, $a, $operation, $vars, $state, $joinType, $nodeId, $aggFromMap, $context, $extensions)->cast(@SelectWithCursor); }, $topQuery); } @@ -2892,7 +2892,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWindowColumn( sortInfo:SortInformation[*], name : String[1], aggSpec: Any[1], - currentPropertyMapping:PropertyMapping[*], topQuery:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] + currentPropertyMapping:PropertyMapping[*], topQuery:SelectWithCursor[1], operation:SelectWithCursor[1], vars:Map[1], state:State[1], joinType:JoinType[1], nodeId:String[1], aggFromMap:List[1], context:DebugContext[1], extensions:Extension[*]):RelationalOperationElement[1] { let newColumnName = $name; @@ -2918,7 +2918,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWindowColumn( //let aggOperation = $aggSpec->reprocessVS()->reactivate($state.inScopeVars)->evaluateAndDeactivate(); let func = $aggSpec->match( [ - o:OlapOperation[1] | processTdsOlapOperation($o, ^$topQuery(select=$mainSelect),$vars,$currentPropertyMapping,$state,$context);, + o:OlapOperation[1] | processTdsOlapOperation($o, ^$operation(select=$mainSelect),$vars,$currentPropertyMapping,$state,$context);, a:meta::pure::metamodel::relation::AggColSpec[1] | let aggContainer = ^AggContainer(name=$a.name,map=$a.map,reduce=$a.reduce); processTDSMapReduce($aggContainer, $mainSelect, true, $currentPropertyMapping, $vars, ^$state(currentWindow=if($newFlow,|$window,|[])), $context);, func : meta::pure::metamodel::relation::FuncColSpec[1] | let aggContainer = ^AggContainer(name=$func.name,map=$func.function); @@ -2943,7 +2943,7 @@ function meta::relational::functions::pureToSqlQuery::processTdsWindowColumn( ); let newPath = pair($newColumnName, ^PathInformation(type=$pureType, relationalType= meta::relational::transform::fromPure::pureTypeToDataType($pureType))); - ^$mainSelect(columns = $mainSelect.columns->concatenate($windowColumn), paths +=$newPath)->isolateSubSelectIfNotLastOperation($topQuery, $f, $state.functionExpressionStack, $extensions); + ^$mainSelect(columns = $mainSelect.columns->concatenate($windowColumn), paths +=$newPath)->isolateSubSelectIfNotLastOperation($operation, $f, $state.functionExpressionStack, $extensions); } function meta::relational::functions::pureToSqlQuery::extractName(o:Any[0..1]):String[1]