Skip to content

Commit

Permalink
Merge branch 'finos:master' into pamnar-mastery-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Arik Pamnani authored Nov 30, 2023
2 parents 86597bb + 8e935d4 commit 07a213d
Show file tree
Hide file tree
Showing 20 changed files with 487 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ private void registerStrings()
register("meta::pure::functions::string::trim_String_1__String_1_", true, ps -> res("String", "one"));
register("meta::pure::functions::string::ltrim_String_1__String_1_", true, ps -> res("String", "one"));
register("meta::pure::functions::string::rtrim_String_1__String_1_", true, ps -> res("String", "one"));
register("meta::pure::functions::string::left_String_1__Integer_1__String_1_", false, ps -> res("String", "one"));
register("meta::pure::functions::string::right_String_1__Integer_1__String_1_", false, ps -> res("String", "one"));
register(m(m(h("meta::pure::functions::string::lpad_String_1__Integer_1__String_1_", false, ps -> res("String", "one"), ps -> ps.size() == 2)),
m(h("meta::pure::functions::string::lpad_String_1__Integer_1__String_1__String_1_", false, ps -> res("String", "one"), ps -> true))));

Expand Down Expand Up @@ -2073,6 +2075,8 @@ private Map<String, Dispatch> buildDispatch()
map.put("meta::pure::functions::string::trim_String_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 1 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())));
map.put("meta::pure::functions::string::ltrim_String_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 1 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())));
map.put("meta::pure::functions::string::rtrim_String_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 1 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())));
map.put("meta::pure::functions::string::left_String_1__Integer_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 2 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())) && isOne(ps.get(1)._multiplicity()) && ("Nil".equals(ps.get(1)._genericType()._rawType()._name()) || "Integer".equals(ps.get(1)._genericType()._rawType()._name())));
map.put("meta::pure::functions::string::right_String_1__Integer_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 2 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())) && isOne(ps.get(1)._multiplicity()) && ("Nil".equals(ps.get(1)._genericType()._rawType()._name()) || "Integer".equals(ps.get(1)._genericType()._rawType()._name())));
map.put("meta::pure::functions::string::lpad_String_1__Integer_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 2 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())) && isOne(ps.get(1)._multiplicity()) && ("Nil".equals(ps.get(1)._genericType()._rawType()._name()) || "Integer".equals(ps.get(1)._genericType()._rawType()._name())));
map.put("meta::pure::functions::string::lpad_String_1__Integer_1__String_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 3 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())) && isOne(ps.get(1)._multiplicity()) && ("Nil".equals(ps.get(1)._genericType()._rawType()._name()) || "Integer".equals(ps.get(1)._genericType()._rawType()._name())) && isOne(ps.get(2)._multiplicity()) && ("Nil".equals(ps.get(2)._genericType()._rawType()._name()) || "String".equals(ps.get(2)._genericType()._rawType()._name())));
map.put("meta::pure::functions::string::rpad_String_1__Integer_1__String_1_", (List<ValueSpecification> ps) -> ps.size() == 2 && isOne(ps.get(0)._multiplicity()) && ("Nil".equals(ps.get(0)._genericType()._rawType()._name()) || "String".equals(ps.get(0)._genericType()._rawType()._name())) && isOne(ps.get(1)._multiplicity()) && ("Nil".equals(ps.get(1)._genericType()._rawType()._name()) || "Integer".equals(ps.get(1)._genericType()._rawType()._name())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ Class meta::legend::test::handlers::model::TestString
lpad(){$this.string->lpad(1)}:String[1];
lpad2(){$this.string->lpad(1, '0')}:String[1];
rpad(){$this.string->rpad(1)}:String[1];
rpad2(){$this.string->rpad(1, '0')}:String[1];
rpad2(){$this.string->rpad(1, '0')}:String[1];
left(){$this.string->left(1)}:String[1];
right(){$this.string->right(1)}:String[1];

parseBoolean(){$this.string->parseBoolean()}:Boolean[1];
parseDate(){$this.string->parseDate()}:Date[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,34 @@ function {doc.doc = 'Lower cases the first charater of the provided string'} met
})
}

function {doc.doc = 'Return first n characters in the string'}
meta::pure::functions::string::left(string:String[1], length:Integer[1]):String[1]
{
assert($length >= 0, 'length must be >= 0');

let strLength = $string->length();

let digits = if ($length > $strLength,
| $strLength,
| $length);

$string->substring(0, $digits);
}

function {doc.doc = 'Return last n characters in the string'}
meta::pure::functions::string::right(string:String[1], length:Integer[1]):String[1]
{
assert($length >= 0, 'length must be >= 0');

let strLength = $string->length();

let digits = if ($length > $strLength,
| 0,
| $strLength - $length);

$string->substring($digits, $strLength);
}

function meta::pure::functions::string::repeatString(str:String[0..1], times:Integer[1]):String[0..1]
{
if ($str->isNotEmpty(), | $str->toOne()->repeat($times)->joinStrings(), | []);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2023 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.

function <<test.Test>> meta::pure::functions::string::tests::left::leftTest():Boolean[1] {

assertEquals('ab', 'abcde'->left(2));
assertEquals('', 'abcde'->left(0));
assertEquals('abcde', 'abcde'->left(7));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2023 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.

function <<test.Test>> meta::pure::functions::string::tests::right::rightTest():Boolean[1] {

assertEquals('de', 'abcde'->right(2));
assertEquals('', 'abcde'->right(0));
assertEquals('abcde', 'abcde'->right(7));
}
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ function meta::pure::router::routing::shouldStopFunctions(extensions:meta::pure:
lpad_String_1__Integer_1__String_1__String_1_,
rpad_String_1__Integer_1__String_1_,
rpad_String_1__Integer_1__String_1__String_1_,
left_String_1__Integer_1__String_1_,
right_String_1__Integer_1__String_1_,
meta::pure::tds::extensions::firstNotNull_T_MANY__T_$0_1$_,
meta::pure::functions::date::calendar::annualized_Date_1__String_1__Date_1__Number_$0_1$__Number_$0_1$_,
meta::pure::functions::date::calendar::cme_Date_1__String_1__Date_1__Number_$0_1$__Number_$0_1$_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::postg
dynaFnToSql('hour', $allStates, ^ToSql(format='date_part(\'hour\', %s)')),
dynaFnToSql('indexOf', $allStates, ^ToSql(format='strpos(%s, %s)')),
dynaFnToSql('joinStrings', $allStates, ^ToSql(format='string_agg(%s, %s)')),
dynaFnToSql('left', $allStates, ^ToSql(format='left(%s, %s)')),
dynaFnToSql('length', $allStates, ^ToSql(format='char_length(%s)')),
dynaFnToSql('minute', $allStates, ^ToSql(format='date_part(\'minute\', %s)')),
dynaFnToSql('mod', $allStates, ^ToSql(format='mod(%s,%s)')),
Expand All @@ -195,9 +196,10 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::postg
dynaFnToSql('parseFloat', $allStates, ^ToSql(format='cast(%s as float)')),
dynaFnToSql('parseInteger', $allStates, ^ToSql(format='cast(%s as integer)')),
dynaFnToSql('position', $allStates, ^ToSql(format='position(%s in %s)')),
dynaFnToSql('quarter', $allStates, ^ToSql(format='quarter(%s)')),
dynaFnToSql('quarter', $allStates, ^ToSql(format='date_part(\'quarter\', %s)')),
dynaFnToSql('quarterNumber', $allStates, ^ToSql(format='date_part(\'quarter\', %s)')),
dynaFnToSql('rem', $allStates, ^ToSql(format='mod(%s,%s)')),
dynaFnToSql('right', $allStates, ^ToSql(format='right(%s, %s)')),
dynaFnToSql('round', $allStates, ^ToSql(format='round((%s)::numeric, %s)', transform=transformRound_String_MANY__String_MANY_)),
dynaFnToSql('second', $allStates, ^ToSql(format='date_part(\'second\', %s)')),
dynaFnToSql('substring', $allStates, ^ToSql(format='substring%s', transform={p:String[*]|$p->joinStrings('(', ', ', ')')})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ private Result executeRelationalCrossRootQueryTempTableGraphFetchExecutionNode(R
{
}
node.parentTempTableStrategy.createTempTableNode.accept(new ExecutionNodeExecutor(this.profiles, this.executionState));
loadValuesIntoTempTablesFromRelationalResult(node.parentTempTableStrategy.loadTempTableNode, parentRealizedRelationalResult, ((LoadFromResultSetAsValueTuplesTempTableStrategy) node.parentTempTableStrategy).tupleBatchSize, ((LoadFromResultSetAsValueTuplesTempTableStrategy) node.tempTableStrategy).quoteCharacterReplacement, databaseTimeZone, this.executionState, this.profiles);
loadValuesIntoTempTablesFromRelationalResult(node.parentTempTableStrategy.loadTempTableNode, parentRealizedRelationalResult, ((LoadFromResultSetAsValueTuplesTempTableStrategy) node.parentTempTableStrategy).tupleBatchSize, ((LoadFromResultSetAsValueTuplesTempTableStrategy) node.parentTempTableStrategy).quoteCharacterReplacement, databaseTimeZone, this.executionState, this.profiles);
}
else if (node.parentTempTableStrategy instanceof LoadFromTempFileTempTableStrategy)
{
Expand Down
Loading

0 comments on commit 07a213d

Please sign in to comment.