Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::functions::flow::*;
import meta::pure::metamodel::variant::*;
import meta::pure::functions::variant::convert::*;
import meta::pure::functions::variant::navigation::*;
Expand All @@ -29,8 +30,16 @@ Class meta::pure::functions::relation::tests::composition::FirmTypeForCompositio

Class meta::pure::functions::relation::tests::composition::PersonTypeForCompositionTests
{
firstName : String[1];
lastName : String[1];
firstName : String[0..1];
lastName : String[0..1];
}

Class meta::pure::functions::relation::tests::composition::SimpleNumbersTypeForCompositionTests
{
id : Integer[1];
val1 : Number[1];
val2 : Number[1];
val3 : Number[1];
}

function <<PCT.test>> meta::pure::functions::relation::tests::composition::testExtendFilter<T|m>(f:Function<{Function<{->T[m]}>[1]->T[m]}>[1]):Boolean[1]
Expand Down Expand Up @@ -1472,4 +1481,106 @@ meta::pure::functions::relation::tests::composition::TestJoin_CurrentUserId<T|m>
' 1,More Test 1,user1,null,null\n'+
' 2,More Test 2,root,null,null\n'+
'#', $res->sort(~id->ascending())->toString());
}

function <<PCT.test>> meta::pure::functions::relation::tests::composition::testMultiCoalesceInProject<T|m>(f:Function<{Function<{->T[m]}>[1]->T[m]}>[1]):Boolean[1]
{
let expr = {|
[
^PersonTypeForCompositionTests(firstName = 'Peter', lastName = 'Smith'),
^PersonTypeForCompositionTests(lastName = 'Johnson'),
^PersonTypeForCompositionTests(firstName = 'Anthony'),
^PersonTypeForCompositionTests()
]
->project(~[name : x | coalesce($x.firstName, $x.lastName, 'Anonymous'), firstName : x | coalesce($x.firstName, 'Empty')])
};

let res = $f->eval($expr);

assertEquals( '#TDS\n' +
' name,firstName\n' +
' Peter,Peter\n' +
' Johnson,Empty\n' +
' Anthony,Anthony\n' +
' Anonymous,Empty\n' +
'#', $res->sort([~name->descending()])->toString());
}

function <<PCT.test, PCTRelationQualifier.relation>> meta::pure::functions::relation::tests::composition::testCoalesceInPreFilter<T|m>(f:Function<{Function<{->T[m]}>[1]->T[m]}>[1]):Boolean[1]
{
let expr = {|
[
^PersonTypeForCompositionTests(firstName = 'Peter', lastName = 'Smith'),
^PersonTypeForCompositionTests(firstName = 'John', lastName = 'Johnson'),
^PersonTypeForCompositionTests(lastName = 'Peter'),
^PersonTypeForCompositionTests(firstName = 'Anthony', lastName = 'Allen')
]
->filter(x|'Peter' == coalesce($x.firstName, $x.lastName))
->size()
};

let res = $f->eval($expr);

assertEquals(2, $res);
}

function <<PCTRelationQualifier.relation, PCT.test>> meta::pure::functions::relation::tests::composition::testTDSPlusTimesMinus<T|m>(f:Function<{Function<{->T[m]}>[1]->T[m]}>[1]):Boolean[1]
{
let expr = {
|#TDS
id, val, val2
1, 1, 2
2, 3, 5
3, 4, 9
4, 5, 14
5, 6, 20
#->project(~[
plus:c|$c.val->toOne() + $c.val2->toOne(),
times:c|$c.val->toOne() * $c.val2->toOne(),
minus:c|$c.val->toOne() - $c.val2->toOne()
])
};

let res = $f->eval($expr);

assertEquals( '#TDS\n'+
' plus,times,minus\n'+
' 3,2,-1\n'+
' 8,15,-2\n'+
' 13,36,-5\n'+
' 19,70,-9\n'+
' 26,120,-14\n'+
'#', $res->sort([~plus->ascending()])->toString());
}

function <<PCT.test, PCTRelationQualifier.relation>> meta::pure::functions::relation::tests::composition::testProjectNumbersPlusTimesMinus<T|m>(f:Function<{Function<{->T[m]}>[1]->T[m]}>[1]):Boolean[1]
{
let expr = {|
[
^SimpleNumbersTypeForCompositionTests(id = 1, val1 = 1, val2 = 1, val3 = 1.0),
^SimpleNumbersTypeForCompositionTests(id = 2, val1 = 31, val2 = 23, val3 = 0.0),
^SimpleNumbersTypeForCompositionTests(id = 3, val1 = 7, val2 = 97, val3 = 72.0),
^SimpleNumbersTypeForCompositionTests(id = 4, val1 = 5, val2 = 3, val3 = 89.0)
]
->project(~[
id:v|$v.id,
plus:v|plus([$v.val1, $v.val2, $v.val3]),
times:v|times([$v.val1, $v.val2, $v.val3]),
minus:v|minus([$v.val1, $v.val2, $v.val3])
])
};

let res = $f->eval($expr);

meta::pure::functions::relation::assertTdsEquivalent(
#TDS
id,plus,times,minus
1,3.0,1.0,-1.0
2,54.0,0.0,8.0
3,176.0,48888.0,-162.0
4,97.0,1335.0,-87.0
#,
$res->sort(~id->ascending()),
0.01
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class Test_Interpreted_RelationFunctions_PCT extends PCTReportConfigurati
one("meta::pure::functions::relation::tests::composition::testExtendAddOnNull_Function_1__Boolean_1_", "\"\nexpected: '#TDS\n id,grp,newCol\n null,0,null\n 8,1,8\n null,1,8\n null,1,8\n 1,2,6\n 5,2,6\n 3,3,10\n 7,3,10\n 4,4,4\n 9,5,9\n#'\nactual: '#TDS\n id,grp,newCol\n null,0,0\n 8,1,8\n null,1,8\n null,1,8\n 1,2,6\n 5,2,6\n 3,3,10\n 7,3,10\n 4,4,4\n 9,5,9\n#'\""),
one("meta::pure::functions::relation::tests::composition::testExtendFilterOutNull_Function_1__Boolean_1_", "\"\nexpected: '#TDS\n p,o,i,newCol\n 300,2,20,30\n 300,1,10,30\n 200,3,30,80\n 200,3,30,80\n 200,1,10,80\n 200,1,10,80\n 100,3,30,60\n 100,2,20,60\n 100,1,10,60\n 0,1,10,20\n 0,1,10,20\n#'\nactual: '#TDS\n p,o,i,newCol\n 300,2,20,30\n 300,1,10,30\n 200,3,30,110\n 200,3,30,110\n 200,1,10,110\n 200,1,10,110\n 100,3,30,110\n 100,2,20,110\n 100,1,10,110\n 0,1,10,50\n 0,1,10,50\n#'\""),
// empty vs null
one("meta::pure::functions::relation::tests::composition::testVariantColumn_slice_Function_1__Boolean_1_", "\"\nexpected: '#TDS\n id,payload,fromRow,toRow,sliced\n 0,\"null\",1,2,\"null\"\n 1,\"[1,2,3,4,5,6]\",2,3,\"[3]\"\n 2,\"[1,2,3,4,5,6]\",0,4,\"[1,2,3,4]\"\n 3,\"[1,2,3,4,5,6]\",-3,-1,\"[]\"\n#'\nactual: '#TDS\n id,payload,fromRow,toRow,sliced\n 0,\"null\",1,2,\"null\"\n 1,\"[1,2,3,4,5,6]\",2,3,\"3\"\n 2,\"[1,2,3,4,5,6]\",0,4,\"[1,2,3,4]\"\n 3,\"[1,2,3,4,5,6]\",-3,-1,\"null\"\n#'\"")
one("meta::pure::functions::relation::tests::composition::testVariantColumn_slice_Function_1__Boolean_1_", "\"\nexpected: '#TDS\n id,payload,fromRow,toRow,sliced\n 0,\"null\",1,2,\"null\"\n 1,\"[1,2,3,4,5,6]\",2,3,\"[3]\"\n 2,\"[1,2,3,4,5,6]\",0,4,\"[1,2,3,4]\"\n 3,\"[1,2,3,4,5,6]\",-3,-1,\"[]\"\n#'\nactual: '#TDS\n id,payload,fromRow,toRow,sliced\n 0,\"null\",1,2,\"null\"\n 1,\"[1,2,3,4,5,6]\",2,3,\"3\"\n 2,\"[1,2,3,4,5,6]\",0,4,\"[1,2,3,4]\"\n 3,\"[1,2,3,4,5,6]\",-3,-1,\"null\"\n#'\""),

one("meta::pure::functions::relation::tests::composition::testProjectNumbersPlusTimesMinus_Function_1__Boolean_1_", "Execution error at (resource:/core_functions_relation/relation/tests/composition.pure line:1565 column:24)")
);

public static Test suite()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public class Test_Deephaven_RelationFunctions_PCT extends PCTReportConfiguration
one("meta::pure::functions::relation::tests::composition::test_Slice_Size_Function_1__Boolean_1_", "\"function not supported yet: meta::pure::functions::relation::size_Relation_1__Integer_1_\""),
one("meta::pure::functions::relation::tests::composition::testGroupBy_Conflicting_Alias_With_Table_Columns_Function_1__Boolean_1_", "function not supported yet: meta::pure::functions::relation::groupBy_Relation_1__ColSpec_1__AggColSpecArray_1__Relation_1_"),
one("meta::pure::functions::relation::tests::composition::TestJoin_CurrentUserId_Function_1__Boolean_1_", "\"Match failure: LambdaFunctionObject instanceOf LambdaFunction\""),
one("meta::pure::functions::relation::tests::composition::testCoalesceInPreFilter_Function_1__Boolean_1_", "\"function not supported yet: meta::pure::functions::collection::size_Any_MANY__Integer_1_\""),
one("meta::pure::functions::relation::tests::composition::testMultiCoalesceInProject_Function_1__Boolean_1_", "\"function not supported yet: meta::pure::functions::relation::project_C_MANY__FuncColSpecArray_1__Relation_1_\""),
one("meta::pure::functions::relation::tests::composition::testProjectNumbersPlusTimesMinus_Function_1__Boolean_1_", "\"function not supported yet: meta::pure::functions::relation::project_C_MANY__FuncColSpecArray_1__Relation_1_\""),
one("meta::pure::functions::relation::tests::composition::testTDSPlusTimesMinus_Function_1__Boolean_1_", "\"function not supported yet: meta::pure::functions::relation::project_Relation_1__FuncColSpecArray_1__Relation_1_\""),

one("meta::pure::functions::relation::tests::concatenate::testSimpleConcatenateShared_Function_1__Boolean_1_", "\"function not supported yet: meta::pure::functions::relation::concatenate_Relation_1__Relation_1__Relation_1_\""),
one("meta::pure::functions::relation::tests::concatenate::testSimpleConcatenate_MultipleExpressions_Function_1__Boolean_1_", "\"Match failure: LambdaFunctionObject instanceOf LambdaFunction\""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public class Test_JAVA_RelationFunction_PCT extends PCTReportConfiguration
one("meta::pure::functions::relation::variant::tests::flatten::testFlatten_LateralJoin_Nested_Extend_Function_1__Boolean_1_", "\"Instance of type 'meta::pure::metamodel::relation::TDS' can't be translated\"", AdapterQualifier.unsupportedFeature),
one("meta::pure::functions::relation::tests::composition::testExtendAddOnNull_Function_1__Boolean_1_", "\"Instance of type 'meta::pure::metamodel::relation::TDS' can't be translated\"", AdapterQualifier.unsupportedFeature),
one("meta::pure::functions::relation::tests::composition::testExtendFilterOutNull_Function_1__Boolean_1_", "\"Instance of type 'meta::pure::metamodel::relation::TDS' can't be translated\"", AdapterQualifier.unsupportedFeature),
one("meta::pure::functions::relation::tests::composition::testProjectOfComputedColumn_withCast_Function_1__Boolean_1_", "\"Instance of type 'meta::pure::metamodel::relation::TDS' can't be translated\"", AdapterQualifier.unsupportedFeature)
one("meta::pure::functions::relation::tests::composition::testProjectOfComputedColumn_withCast_Function_1__Boolean_1_", "\"Instance of type 'meta::pure::metamodel::relation::TDS' can't be translated\"", AdapterQualifier.unsupportedFeature),
one("meta::pure::functions::relation::tests::composition::testMultiCoalesceInProject_Function_1__Boolean_1_", "Error in 'test::testFunction': Can't find a match for function 'new(Class<PersonTypeForCompositionTests>[1],String[1])'.\nFunctions that can match if number of parameters are changed:\n new(Class<T>[1],String[1],KeyExpression[*]):T[1]\n", AdapterQualifier.unsupportedFeature),
one("meta::pure::functions::relation::tests::composition::testProjectNumbersPlusTimesMinus_Function_1__Boolean_1_", "\"meta::pure::functions::relation::project_C_MANY__FuncColSpecArray_1__Relation_1_ is not supported yet!\"", AdapterQualifier.unsupportedFeature)
);

public static Test suite()
Expand Down
Loading
Loading