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 @@ -90,6 +90,7 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::bigQu
dynaFnToSql('quarterNumber', $allStates, ^ToSql(format='extract( quarter from %s)')),
dynaFnToSql('round', $allStates, ^ToSql(format='round(%s, 0)')),
dynaFnToSql('second', $allStates, ^ToSql(format='extract( second from %s)')),
dynaFnToSql('split', $allStates, ^ToSql(format='split(%s, %s)')),
dynaFnToSql('stdDevPopulation', $allStates, ^ToSql(format='stddev_pop(%s)')),
dynaFnToSql('stdDevSample', $allStates, ^ToSql(format='stddev_samp(%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 @@ -600,12 +600,6 @@
}, {
"test" : "meta::pure::functions::string::tests::parseInteger::testParseInteger_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 9999999999999992\nactual: 1874919416\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
}, {
"test" : "meta::pure::functions::string::tests::startswith::testFalseStartsWith_Function_1__Boolean_1_",
"expectedError" : "class java.lang.Long cannot be cast to class java.lang.Boolean (java.lang.Long and java.lang.Boolean are in module java.base of loader 'bootstrap')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::click
dynaFnToSql('second', $allStates, ^ToSql(format='toSecond(%s)')),
dynaFnToSql('sha1', $allStates, ^ToSql(format='lower(hex(SHA1(%s)))')),
dynaFnToSql('sha256', $allStates, ^ToSql(format='lower(hex(SHA256(%s)))')),
dynaFnToSql('split', $allStates, ^ToSql(format='splitByString(%s, %s)', transform={p:String[2] | [$p->at(1), $p->at(0)]})),
dynaFnToSql('splitPart', $allStates, ^ToSql(format='splitByString(%s, %s)[%s]', transform={p:String[*] | $p->at(1)->concatenate($p->at(0))->concatenate($p->at(2))})),
dynaFnToSql('substring', $allStates, ^ToSql(format='substring(%s)', transform={p:String[*]|$p->transformSubstringForClickHouse()})),
dynaFnToSql('stdDevPopulation', $allStates, ^ToSql(format='%s', transform={p:String[*] | transformWithArrayReduceForClickHouse('stddevPop', $p)})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,6 @@
}, {
"test" : "meta::pure::functions::string::tests::parseDecimal::testParseZero_Function_1__Boolean_1_",
"expectedError" : "\nexpected: 0.0D\nactual: 0D"
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki."
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki."
}, {
"test" : "meta::pure::functions::string::tests::substring::testStartEnd_Function_1__Boolean_1_",
"expectedError" : "\nexpected: 'he quick brown fox jumps over the lazy do'\nactual: 'the quick brown fox jumps over the lazy do'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::datab
dynaFnToSql('round', $allStates, ^ToSql(format='round(%s, %s)', transform=transformRound_String_MANY__String_MANY_)),
dynaFnToSql('second', $allStates, ^ToSql(format='second(%s)')),
dynaFnToSql('sha256', $allStates, ^ToSql(format='sha2(%s, 256)')),
dynaFnToSql('split', $allStates, ^ToSql(format='split(%s, %s)')),
dynaFnToSql('sqlFalse', $allStates, ^ToSql(format='false')),
dynaFnToSql('sqlTrue', $allStates, ^ToSql(format='true')),
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 @@ -399,12 +399,6 @@
}, {
"test" : "meta::pure::functions::string::tests::parseDecimal::testParseZero_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 0.000D\nactual: 0.0D\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
}, {
"test" : "meta::pure::functions::string::tests::substring::testStartEnd_Function_1__Boolean_1_",
"expectedError" : "Assert failure at (resource:/platform/pure/essential/tests/assert.pure line:21 column:5), \"\nexpected: 'the quick brown fox jumps over the lazy dog'\nactual: 'the quick brown fox jumps over the lazy do'\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::duckD
dynaFnToSql('second', $allStates, ^ToSql(format='second(%s)')),
dynaFnToSql('sha1', $allStates, ^ToSql(format='sha1(%s)')),
dynaFnToSql('sha256', $allStates, ^ToSql(format='sha256(%s)')),
dynaFnToSql('split', $allStates, ^ToSql(format='string_split(%s, %s)')),
dynaFnToSql('splitPart', $allStates, ^ToSql(format='split_part(%s, %s, %s)')),
dynaFnToSql('substring', $allStates, ^ToSql(format='substring%s', transform={p:String[*]|$p->joinStrings('(', ', ', ')')})), // TODO - pure uses 0-based indexing, duck db returns location with 1-based index , keeping this as H2 also returns 1-based currently, many user tests need to be fixed
dynaFnToSql('stdDevPopulation', $allStates, ^ToSql(format='stddev_pop(%s)')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,6 @@
}, {
"test" : "meta::pure::functions::string::tests::parseInteger::testParseInteger_Function_1__Boolean_1_",
"expectedError" : "org.h2.jdbc.JdbcSQLDataException: Data conversion error converting \"9999999999999992\"; SQL statement:\nselect cast('9999999999999992' as integer) [22018-214]"
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
}, {
"test" : "meta::pure::functions::string::tests::substring::testStartEnd_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 'he quick brown fox jumps over the lazy do'\nactual: 'the quick brown fox jumps over the lazy do'\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@
"expectedError" : "\"\nexpected: 0.0D\nactual: 0D\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::startswith::testFalseStartsWith_Function_1__Boolean_1_",
"expectedError" : "class java.lang.Long cannot be cast to class java.lang.Boolean (java.lang.Long and java.lang.Boolean are in module java.base of loader 'bootstrap')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@
"expectedError" : "\"\nexpected: ['']\nactual: []\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'"
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'"
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::startswith::testFalseStartsWith_Function_1__Boolean_1_",
"expectedError" : "class java.lang.String cannot be cast to class java.lang.Boolean (java.lang.String and java.lang.Boolean are in module java.base of loader 'bootstrap')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,6 @@
}, {
"test" : "meta::pure::functions::string::tests::parseInteger::testParseInteger_Function_1__Boolean_1_",
"expectedError" : "org.postgresql.util.PSQLException: ERROR: value \"9999999999999992\" is out of range for type integer"
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
}, {
"test" : "meta::pure::functions::string::tests::substring::testStartEnd_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 'the quick brown fox jumps over the lazy dog'\nactual: 'the quick brown fox jumps over the lazy do'\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::postg
dynaFnToSql('second', $allStates, ^ToSql(format='date_part(\'second\', %s)')),
dynaFnToSql('sha1', $allStates, ^ToSql(format='encode(digest(%s, \'sha1\'), \'hex\')')),
dynaFnToSql('sha256', $allStates, ^ToSql(format='encode(digest(%s, \'sha256\'), \'hex\')')),
dynaFnToSql('split', $allStates, ^ToSql(format='string_to_array(%s, %s)')),
dynaFnToSql('substring', $allStates, ^ToSql(format='substring%s', transform={p:String[*]|$p->joinStrings('(', ', ', ')')})),
dynaFnToSql('stdDevPopulation', $allStates, ^ToSql(format='stddev_pop(%s)')),
dynaFnToSql('stdDevSample', $allStates, ^ToSql(format='stddev_samp(%s)')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,6 @@
}, {
"test" : "meta::pure::functions::string::tests::parseDecimal::testParseZero_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 0.0D\nactual: 0D\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
}, {
"test" : "meta::pure::functions::string::tests::substring::testStartEnd_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 'he quick brown fox jumps over the lazy do'\nactual: 'the quick brown fox jumps over the lazy do'\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ function <<access.private>> meta::relational::functions::sqlQueryToString::snowf
dynaFnToSql('substring', $allStates, ^ToSql(format='substring%s', transform={p:String[*]|$p->joinStrings('(', ', ', ')')})),
dynaFnToSql('stdDevPopulation', $allStates, ^ToSql(format='stddev_pop(%s)')),
dynaFnToSql('stdDevSample', $allStates, ^ToSql(format='stddev_samp(%s)')),
dynaFnToSql('split', $allStates, ^ToSql(format='split(%s, %s)')),
dynaFnToSql('splitPart', $allStates, ^ToSql(format='split_part(%s, %s, %s)')),
dynaFnToSql('timeBucket', $allStates, ^ToSql(format='TIME_SLICE(%s)', transform={p:String[3]|$p->at(0) + ', ' + constructInterval($p->at(2), $p->at(1))})),
dynaFnToSql('today', $allStates, ^ToSql(format='current_date')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,10 @@
"expectedError" : "\"[unsupported-api] The function 'parseInteger' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::substring::testStartEnd_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 'he quick brown fox jumps over the lazy do'\nactual: 'the quick brown fox jumps over the lazy do'\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,10 @@
"expectedError" : "\"Failed to execute plan - RuntimeException - com.microsoft.sqlserver.jdbc.SQLServerException: The conversion of the varchar value '9999999999999992' overflowed an int column.\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'."
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::startswith::testFalseStartsWith_Function_1__Boolean_1_",
"expectedError" : "com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'like'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,10 @@
"expectedError" : "Cannot cast '9999999999999992' to INT"
}, {
"test" : "meta::pure::functions::string::tests::split::testSplitWithNoSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::split::testSplit_Function_1__Boolean_1_",
"expectedError" : "\"No SQL translation exists for the PURE function 'split_String_1__String_1__String_MANY_'. \nIf you would like to add a SQL translation for the function then follow the step-by-step guide on the PURE wiki.\""
"expectedError" : "\"[unsupported-api] The function 'split' (state: [Select, false]) is not supported yet\""
}, {
"test" : "meta::pure::functions::string::tests::substring::testStartEnd_Function_1__Boolean_1_",
"expectedError" : "\"\nexpected: 'the quick brown fox jumps over the lazy dog'\nactual: ''\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.h2.value.ValueReal;
import org.h2.value.ValueTimestamp;
import org.h2.value.ValueVarchar;
import java.util.regex.Pattern;

import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -215,6 +216,19 @@ public static String legend_h2_extension_split_part(String string, String token,
return parts.length > readjustedPart ? parts[readjustedPart] : null;
}

public static String[] legend_h2_extension_split(String string, String delimiter)
{
if (string == null)
{
return null;
}
if (delimiter == null || delimiter.isEmpty())
{
return new String[]{string};
}
return string.split(Pattern.quote(delimiter), -1);
}

private static HashSet<Object> extractProperty(HashSet<Object> resultSet, Object pathToExtract)
{
HashSet<Object> res = new HashSet<>();
Expand Down
Loading
Loading