Skip to content

Commit

Permalink
Add support for Frame in OLAP protocol (finos#3014)
Browse files Browse the repository at this point in the history
* Add support for OLAP frame

* Update Pure version
  • Loading branch information
pierredebelen authored Aug 14, 2024
1 parent cb65777 commit 7a29ff9
Show file tree
Hide file tree
Showing 71 changed files with 1,044 additions and 324 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public static String buildHTML()
MutableListMultimap<String, FunctionDocumentation> ordered = Lists.mutable.withAll(doc.functionsDocumentation)
.groupBy(x ->
{
System.out.println(x.functionDefinition.name);
String id = x.functionDefinition.sourceId;
return id.substring(x.reportScope.filePath.length(), id.lastIndexOf("/"));
});
Expand All @@ -72,12 +71,14 @@ public static String buildHTML()
.forEach(x ->
{
TreeNode node = root;
//System.out.println(x.getOne());
// System.out.println(x.getTwo().collect(e -> e.functionDefinition.name));
for (String z : x.getOne().split("/"))
{
node = node.createOrReturnChild(z);
}

for (FunctionDocumentation d : x.getTwo().toSortedListBy(v -> v.functionDefinition.name))
for (FunctionDocumentation d : x.getTwo().toSortedListBy(v -> v.functionDefinition.name == null ? "" : v.functionDefinition.name))
{
MutableList<String> row = Lists.mutable.empty();
row.add("<div style='color:#AAAAAA'>" + d.reportScope.module + "</div>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function meta::pure::metamodel::serialization::grammar::printFunctionExpression(
if($functionExpression.parametersValues->isEmpty(),
|$name->toOne()+'()',
|if ($name == 'getAll',
|$functionExpression.parametersValues->at(0)->cast(@InstanceValue).genericType.typeArguments->at(0).rawType->toOne()->cast(@Class<Any>)->elementToPath() + '.all()';,
|$functionExpression.parametersValues->at(0)->cast(@InstanceValue).genericType.rawType->toOne()->cast(@Class<Any>)->elementToPath() + '.all()';,
|let m = special();
if ($m->get($name)->isEmpty(),
| let firstParam = $functionExpression.parametersValues->head()->toOne();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;

native function meta::pure::functions::relation::columns<T>(rel:Relation<T>[1]):Column<Nil,Any|*>[*];
native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::relation::columns<T>(rel:Relation<T>[1]):Column<Nil,Any|*>[*];

function <<test.Test>> meta::pure::functions::relation::tests::columns::testSimpleColumns():Boolean[1]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;

native function <<PCT.function>> meta::pure::functions::relation::map<T,V>(rel:Relation<T>[1], f:Function<{T[1]->V[*]}>[1]):V[*];
native function <<PCT.function, PCT.platformOnly>> meta::pure::functions::relation::map<T,V>(rel:Relation<T>[1], f:Function<{T[1]->V[*]}>[1]):V[*];

function <<test.Test>> meta::pure::functions::relation::tests::map::testSimpleMap():Boolean[1]
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::test::pct::*;

Class meta::pure::functions::relation::_Range extends Frame
{
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::_range(offsetFrom:Integer[1], offsetTo:Integer[1]):_Range[1]
{
^_Range(offsetFrom = ^FrameIntValue(value=$offsetFrom), offsetTo = ^FrameIntValue(value=$offsetTo));
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::_range(offsetFrom:meta::pure::functions::relation::UnboundedFrameValue[1], offsetTo:Integer[1]):_Range[1]
{
^_Range(offsetFrom = $offsetFrom, offsetTo = ^FrameIntValue(value=$offsetTo));
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::_range(offsetFrom:Integer[1], offsetTo:meta::pure::functions::relation::UnboundedFrameValue[1]):_Range[1]
{
^_Range(offsetFrom = ^FrameIntValue(value=$offsetFrom), offsetTo = $offsetTo);
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::_range(offsetFrom:meta::pure::functions::relation::UnboundedFrameValue[1], offsetTo:meta::pure::functions::relation::UnboundedFrameValue[1]):_Range[1]
{
^_Range(offsetFrom = $offsetFrom, offsetTo = $offsetTo);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::test::pct::*;

Class meta::pure::functions::relation::Rows extends Frame
{
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::rows(offsetFrom:Integer[1], offsetTo:Integer[1]):Rows[1]
{
^Rows(offsetFrom = ^FrameIntValue(value=$offsetFrom), offsetTo = ^FrameIntValue(value=$offsetTo));
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::rows(offsetFrom:meta::pure::functions::relation::UnboundedFrameValue[1], offsetTo:Integer[1]):Rows[1]
{
^Rows(offsetFrom = $offsetFrom, offsetTo = ^FrameIntValue(value=$offsetTo));
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::rows(offsetFrom:Integer[1], offsetTo:meta::pure::functions::relation::UnboundedFrameValue[1]):Rows[1]
{
^Rows(offsetFrom = ^FrameIntValue(value=$offsetFrom), offsetTo = $offsetTo);
}

function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::rows(offsetFrom:meta::pure::functions::relation::UnboundedFrameValue[1], offsetTo:meta::pure::functions::relation::UnboundedFrameValue[1]):Rows[1]
{
^Rows(offsetFrom = $offsetFrom, offsetTo = $offsetTo);
}
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::test::pct::*;
import meta::pure::metamodel::relation::*;

Class meta::pure::functions::relation::_Window<T>
Expand All @@ -21,7 +22,10 @@ Class meta::pure::functions::relation::_Window<T>
frame : Frame[0..1];
}

function meta::pure::functions::relation::over<T>(cols:String[*], sortInfo:SortInfo<(?:?)⊆T>[*], frame:Frame[0..1]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(cols:String[*], sortInfo:SortInfo<(?:?)⊆T>[*], frame:Frame[0..1]):_Window<T>[1]
{
^_Window<T>
(
Expand All @@ -31,15 +35,21 @@ function meta::pure::functions::relation::over<T>(cols:String[*], sortInfo:SortI
);
}

function meta::pure::functions::relation::over<T>(cols:ColSpec<(?:?)⊆T>[1]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(cols:ColSpec<(?:?)⊆T>[1]):_Window<T>[1]
{
^_Window<T>
(
partition=$cols.name
);
}

function meta::pure::functions::relation::over<T>(cols:ColSpecArray<(?:?)⊆T>[1]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(cols:ColSpecArray<(?:?)⊆T>[1]):_Window<T>[1]
{
^_Window<T>
(
Expand All @@ -48,32 +58,50 @@ function meta::pure::functions::relation::over<T>(cols:ColSpecArray<(?:?)⊆T>[1
}


function meta::pure::functions::relation::over<T>(sortInfo:SortInfo<(?:?)⊆T>[*]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(sortInfo:SortInfo<(?:?)⊆T>[*]):_Window<T>[1]
{
over([],$sortInfo,[])
}

function meta::pure::functions::relation::over<T>(frame:Frame[1]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(frame:Frame[1]):_Window<T>[1]
{
over([],[],$frame)
}

function meta::pure::functions::relation::over<T>(cols:ColSpec<(?:?)⊆T>[1], sortInfo:SortInfo<(?:?)⊆T>[*]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(cols:ColSpec<(?:?)⊆T>[1], sortInfo:SortInfo<(?:?)⊆T>[*]):_Window<T>[1]
{
over($cols.name,$sortInfo,[])
}

function meta::pure::functions::relation::over<T>(cols:ColSpecArray<(?:?)⊆T>[1], sortInfo:SortInfo<(?:?)⊆T>[*]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(cols:ColSpecArray<(?:?)⊆T>[1], sortInfo:SortInfo<(?:?)⊆T>[*]):_Window<T>[1]
{
over($cols.names,$sortInfo,[])
}

function meta::pure::functions::relation::over<T>(cols:ColSpec<(?:?)⊆T>[1], frame:Frame[1]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(cols:ColSpec<(?:?)⊆T>[1], frame:Frame[1]):_Window<T>[1]
{
over($cols.name,[],$frame)
}

function meta::pure::functions::relation::over<T>(sortInfo:SortInfo<(?:?)⊆T>[*], frame:Frame[1]):_Window<T>[1]
function
<<functionType.NormalizeRequiredFunction,
PCT.function>>
meta::pure::functions::relation::over<T>(sortInfo:SortInfo<(?:?)⊆T>[*], frame:Frame[1]):_Window<T>[1]
{
over([],$sortInfo,$frame)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

Class meta::pure::functions::relation::Rows extends Frame
{
}
import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;

function meta::pure::functions::relation::rows(offsetFrom:Integer[1], offsetTo:Integer[1]):Rows[1]
{
^Rows(offsetFrom = $offsetFrom, offsetTo = $offsetTo);
}
native function <<PCT.function>> meta::pure::functions::relation::cumulativeDistribution<T>(w:Relation<T>[1], r:T[1]):Float[1];
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

Class meta::pure::functions::relation::_Range extends Frame
{
}
import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;

function meta::pure::functions::relation::_range(offsetFrom:Integer[1], offsetTo:Integer[1]):_Range[1]
{
^_Range(offsetFrom = $offsetFrom, offsetTo = $offsetTo);
}
native function <<PCT.function>> meta::pure::functions::relation::denseRank<T>(w:Relation<T>[1], r:T[1]):Integer[1];
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2024 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;

native function <<PCT.function>> meta::pure::functions::relation::ntile<T>(w:Relation<T>[1], r:T[1], tileCount:Integer[1]):Integer[1];
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2024 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;

native function <<PCT.function>> meta::pure::functions::relation::percentRank<T>(w:Relation<T>[1], r:T[1]):Float[1];
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::test::pct::*;
import meta::pure::metamodel::relation::*;

native function meta::pure::functions::relation::rank<T>(w:Relation<T>[1],r:T[1]):Integer[1];
native function <<PCT.function>> meta::pure::functions::relation::rank<T>(w:Relation<T>[1],r:T[1]):Integer[1];
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

Class meta::pure::functions::relation::Frame
{
offsetFrom : Integer[1];
offsetTo : Integer[1];
}
import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;

native function <<PCT.function>> meta::pure::functions::relation::rowNumber<T>(w:Relation<T>[1],r:T[1]):Integer[1];
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

function meta::pure::functions::relation::s(a:Any[0..1]):String[1]
import meta::pure::test::pct::*;

function <<PCT.function, PCT.platformOnly>> meta::pure::functions::relation::s(a:Any[0..1]):String[1]
{
if ($a->isEmpty(),|'null',|$a->toOne()->toString());
}
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::test::pct::*;
import meta::pure::metamodel::relation::*;

native function meta::pure::functions::relation::first<T>(w:Relation<T>[1]):T[1];
native function <<PCT.function>> meta::pure::functions::relation::first<T>(w:Relation<T>[1], f:Frame[1], r:T[1]):T[1];
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::test::pct::*;
import meta::pure::metamodel::relation::*;
import meta::pure::functions::relation::*;

function meta::pure::functions::relation::lag<T>(w:Relation<T>[1],r:T[1]):T[1]
function <<PCT.function>> meta::pure::functions::relation::lag<T>(w:Relation<T>[1],r:T[1]):T[1]
{
lag($w, $r, 1);
}

function meta::pure::functions::relation::lag<T>(w:Relation<T>[1],r:T[1], offset:Integer[1]):T[1]
function <<PCT.function>> meta::pure::functions::relation::lag<T>(w:Relation<T>[1],r:T[1], offset:Integer[1]):T[1]
{
offset($w, $r, -$offset);
}
Loading

0 comments on commit 7a29ff9

Please sign in to comment.