From eb9a9aaefc67456c44cc6ccf99bd433ea90bf800 Mon Sep 17 00:00:00 2001 From: "Garg, Vijay [Engineering]" Date: Tue, 26 Nov 2024 12:27:31 +0000 Subject: [PATCH] use existing lambda method with fullPath=true config --- .../pure/serialization/toPureGrammar.pure | 8 +++---- .../dataquality_test.pure | 4 ++-- .../dataquality_test_utils.pure | 22 +++++++++---------- 3 files changed, 17 insertions(+), 17 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 b0a66ba9175..efc720db41a 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 @@ -112,11 +112,11 @@ function meta::pure::metamodel::serialization::grammar::printInstanceValue(i:Ins f:FunctionDefinition[1] | $f->printFunctionDefinition($configuration, $space+' '), f:FunctionExpression[1] | $f->printPropertyOrFunctionExpression($configuration, $space), cs:ColSpec[1] | '~' + $cs.name->printColName(), - fsc:FuncColSpec[1] | '~' + $fsc.name->printColName() + ':' + $fsc.function->cast(@FunctionDefinition)->printFunctionDefinition(''), - asc:AggColSpec[1] | '~' + $asc.name->printColName() + ':' + $asc.map->cast(@FunctionDefinition)->printFunctionDefinition('') + ':' + $asc.reduce->cast(@FunctionDefinition)->printFunctionDefinition(''), + fsc:FuncColSpec[1] | '~' + $fsc.name->printColName() + ':' + $fsc.function->cast(@FunctionDefinition)->printFunctionDefinition($configuration, ''), + asc:AggColSpec[1] | '~' + $asc.name->printColName() + ':' + $asc.map->cast(@FunctionDefinition)->printFunctionDefinition($configuration, '') + ':' + $asc.reduce->cast(@FunctionDefinition)->printFunctionDefinition(''), csa:ColSpecArray[1] | '~['+$csa.names->map(c|$c->printColName())->joinStrings(',')+']', - fcsa:FuncColSpecArray[1] | '~[' + $fcsa.funcSpecs->map(x| $x.name->printColName() + ':' + $x.function->cast(@FunctionDefinition)->printFunctionDefinition(''))->joinStrings(',') + ']', - acsa:AggColSpecArray[1] | '~[' + $acsa.aggSpecs->map(x| $x.name->printColName() + ':' + $x.map->cast(@FunctionDefinition)->printFunctionDefinition('') + ':' + $x.reduce->cast(@FunctionDefinition)->printFunctionDefinition(''))->joinStrings(',') + ']', + fcsa:FuncColSpecArray[1] | '~[' + $fcsa.funcSpecs->map(x| $x.name->printColName() + ':' + $x.function->cast(@FunctionDefinition)->printFunctionDefinition($configuration, ''))->joinStrings(',') + ']', + acsa:AggColSpecArray[1] | '~[' + $acsa.aggSpecs->map(x| $x.name->printColName() + ':' + $x.map->cast(@FunctionDefinition)->printFunctionDefinition($configuration, '') + ':' + $x.reduce->cast(@FunctionDefinition)->printFunctionDefinition($configuration, ''))->joinStrings(',') + ']', x:InstanceValue[1] | $x->printInstanceValue($configuration, $space), z:KeyExpression[*] | $z->map(f|$f.key.values->toOne()->toString())->joinStrings(','), v:VariableExpression[1] | $v->printValueSpecification($configuration, $space), diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure index 88c0ced0f57..eb7da74a71c 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test.pure @@ -185,7 +185,7 @@ function <> meta::external::dataquality::tests::testLambdaGeneration_ ' assertion: row2|$row2.FIRSTNAME->isNotEmpty();' + ' }' + ' ];' + - ' }','validFirstName', {|#>{meta::external::dataquality::tests::domain::db.personTable}#->select(~[FIRSTNAME, LASTNAME])->extend(~fullname:x|[$x.FIRSTNAME->toOne(), $x.LASTNAME->toOne()]->joinStrings())->filter(row2|$row2.FIRSTNAME->isNotEmpty()->not()) + ' }','validFirstName', {|#>{meta::external::dataquality::tests::domain::db.personTable}#->select(~[FIRSTNAME, LASTNAME])->extend(~fullname:x|[$x.FIRSTNAME->meta::pure::functions::multiplicity::toOne(), $x.LASTNAME->meta::pure::functions::multiplicity::toOne()]->joinStrings())->filter(row2|$row2.FIRSTNAME->meta::pure::functions::collection::isNotEmpty()->meta::pure::functions::boolean::not()) }) } @@ -202,6 +202,6 @@ function <> meta::external::dataquality::tests::testLambdaGeneration_ ' assertion: row2|$row2.FIRSTNAME->size() <= 100;' + ' }' + ' ];' + - ' }','validFirstName', {name:String[1]|#>{meta::external::dataquality::tests::domain::db.personTable}#->select(~FIRSTNAME)->filter({n|($n == $name)})->groupBy(~[FIRSTNAME], ~[count:{x|$x.FIRSTNAME}:{y|$y->count()}])->filter(row2|not(($row2.FIRSTNAME->size() <= 100))) + ' }','validFirstName', {name:String[1]|#>{meta::external::dataquality::tests::domain::db.personTable}#->select(~FIRSTNAME)->filter({n|($n == $name)})->groupBy(~[FIRSTNAME], ~[count:{x|$x.FIRSTNAME}:{y|$y->meta::pure::functions::collection::count()}])->filter(row2|meta::pure::functions::boolean::not(($row2.FIRSTNAME->meta::pure::functions::collection::size() <= 100))) }) } \ No newline at end of file diff --git a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_utils.pure b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_utils.pure index 9a1c36309ff..1c87bc072f8 100644 --- a/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_utils.pure +++ b/legend-engine-xts-dataquality/legend-engine-xt-dataquality-pure-test/src/main/resources/core_dataquality_test/dataquality_test_utils.pure @@ -60,9 +60,18 @@ function meta::external::dataquality::tests::doRelationTest(dq:String[1], valida { let dataqualityRelationValidation = $dq->loadDataQualityRelationValidation(); - let actual = $dataqualityRelationValidation->meta::external::dataquality::generateDataqualityRelationValidationLambda($validationName); + let actual = $dataqualityRelationValidation->meta::external::dataquality::generateDataqualityRelationValidationLambda($validationName, []); - assertRelationLambdaEquals($expected, $actual); + assertLambdaEquals($expected, $actual->cast(@LambdaFunction)); +} + +function meta::external::dataquality::tests::doRelationTestWithLimit(dq:String[1], validationName:String[1], expected:FunctionDefinition[1], resultLimit: Integer[1]):Boolean[1] +{ + let dataqualityRelationValidation = $dq->loadDataQualityRelationValidation(); + + let actual = $dataqualityRelationValidation->meta::external::dataquality::generateDataqualityRelationValidationLambda($validationName, $resultLimit); + + assertLambdaEquals($expected, $actual->cast(@LambdaFunction)); } @@ -88,15 +97,6 @@ function meta::external::dataquality::tests::assertLambdaEquals(expected:Functio assertEquals($expected->printFunctionDefinition($config, ''), $actual->printFunctionDefinition($config, '')); } -function meta::external::dataquality::tests::assertRelationLambdaEquals(expected:FunctionDefinition[1], actual:FunctionDefinition[1]): Boolean[1] -{ - let config = ^meta::pure::metamodel::serialization::grammar::Configuration - ( - fullPath = false - ); - assertEquals($expected->printFunctionDefinition($config, ''), $actual->printFunctionDefinition($config, '')); -} - function meta::external::dataquality::tests::assertLambdaJSONEquals(expected:FunctionDefinition[1], actual:FunctionDefinition[1]): Boolean[1] { assertEquals($expected->functionJSON(), $actual->functionJSON());