Skip to content

Commit 9280692

Browse files
committed
Enable TDS->Relational for Project
1 parent 4b9d1bb commit 9280692

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/tds/relation/tdsToRelation.pure

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ function meta::pure::tds::toRelation::transform(a:AppliedFunction[1], extensions
7070

7171
appliedFunction(project_C_MANY__FuncColSpecArray_1__Relation_1_, [$a.parameters->at(0)->transform($extensions), $columns]);
7272
),
73-
//TODO activate when relation inference is fixed on project
74-
// pair(project_TabularDataSet_1__ColumnSpecification_MANY__TabularDataSet_1_->cast(@Function<Any>),
75-
// |
76-
// let columns = $a.parameters->at(1)->colsToColSpecArrayInstance($extensions);
73+
pair(project_TabularDataSet_1__ColumnSpecification_MANY__TabularDataSet_1_->cast(@Function<Any>),
74+
|
75+
let columns = $a.parameters->at(1)->colsToColSpecArrayInstance($extensions);
7776

78-
// appliedFunction(project_Relation_1__FuncColSpecArray_1__Relation_1_, [$a.parameters->at(0)->transform($extensions), $columns]);
79-
// ),
77+
appliedFunction(project_Relation_1__FuncColSpecArray_1__Relation_1_, [$a.parameters->at(0)->transform($extensions), $columns]);
78+
),
8079
pair(groupBy_K_MANY__Function_MANY__AggregateValue_MANY__String_MANY__TabularDataSet_1_->cast(@Function<Any>),
8180
|
8281
let groupByColumns = $a.parameters->at(1)->fromCollection()->cast(@Lambda);

legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/tds/relation/testTdsToRelation.pure

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -69,38 +69,37 @@ function <<test.Test>> meta::pure::tds::toRelation::testProjectSingle():Boolean[
6969
);
7070
}
7171

72-
//TODO activate when relation inference is fixed on project
73-
// function <<test.Test>> meta::pure::tds::toRelation::testTDSProjectSingle():Boolean[1]
74-
// {
75-
// test(
76-
// {| TestClass.all()
77-
// ->project(col(x | $x.string, 'str'))
78-
// ->project(col(x:TDSRow[1] | $x.getString('str')->toOne() + 'abc', 'newCol'))},
79-
// {| TestClass.all()
80-
// ->project(~[str: x | $x.string])
81-
// ->project(~[newCol : x | $x.str->toOne() + 'abc'])}
82-
// );
83-
// }
84-
85-
// function <<test.Test>> meta::pure::tds::toRelation::testTDSProjectMulti():Boolean[1]
86-
// {
87-
// test(
88-
// {| TestClass.all()
89-
// ->project([col(x | $x.string, 'str'), col(x | $x.integer, 'int')])
90-
// ->project([
91-
// col(x:TDSRow[1] | $x.getString('str')->toOne() + 'abc', 'newCol'),
92-
// col(x:TDSRow[1] | $x.getString('str')->toOne() + 'def', 'newCol2')
93-
// ])},
94-
// {| TestClass.all()
95-
// ->project(~[str: x | $x.string, int: x | $x.integer])
96-
// ->project(~[
97-
// newCol : x | $x.str->toOne() + 'abc',
98-
// newCol2 : x | $x.str->toOne() + 'def'
99-
// ])
100-
// }
101-
// );
102-
// }
10372

73+
function <<test.Test>> meta::pure::tds::toRelation::testTDSProjectSingle():Boolean[1]
74+
{
75+
test(
76+
{| TestClass.all()
77+
->project(col(x | $x.string, 'str'))
78+
->project(col(x:TDSRow[1] | $x.getString('str')->toOne() + 'abc', 'newCol'))},
79+
{| TestClass.all()
80+
->project(~[str: x | $x.string])
81+
->project(~[newCol : x | $x.str->toOne() + 'abc'])}
82+
);
83+
}
84+
85+
function <<test.Test>> meta::pure::tds::toRelation::testTDSProjectMulti():Boolean[1]
86+
{
87+
test(
88+
{| TestClass.all()
89+
->project([col(x | $x.string, 'str'), col(x | $x.integer, 'int')])
90+
->project([
91+
col(x:TDSRow[1] | $x.getString('str')->toOne() + 'abc', 'newCol'),
92+
col(x:TDSRow[1] | $x.getString('str')->toOne() + 'def', 'newCol2')
93+
])},
94+
{| TestClass.all()
95+
->project(~[str: x | $x.string, int: x | $x.integer])
96+
->project(~[
97+
newCol : x | $x.str->toOne() + 'abc',
98+
newCol2 : x | $x.str->toOne() + 'def'
99+
])
100+
}
101+
);
102+
}
104103

105104
function <<test.Test>> meta::pure::tds::toRelation::testExtendSingle():Boolean[1]
106105
{

0 commit comments

Comments
 (0)