Skip to content

Commit 44003d4

Browse files
committed
test: Add end-to-end tests for string functions: bit_length, longest_common_prefix, replace_first
1 parent ec92f2a commit 44003d4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

presto-native-execution/src/test/java/com/facebook/presto/nativeworker/AbstractTestNativeGeneralQueries.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,22 @@ public void testStringFunctions()
10381038
finally {
10391039
dropTableIfExists(tmpTableName);
10401040
}
1041+
1042+
// bit_length
1043+
assertQuery("SELECT bit_length(comment) FROM orders");
1044+
assertQuery("SELECT bit_length(name) FROM nation");
1045+
assertQuery("SELECT bit_length(shipmode) FROM lineitem");
1046+
1047+
// longest_common_prefix
1048+
assertQuery("SELECT longest_common_prefix(name, 'UNITED') FROM nation WHERE name LIKE 'UNITED%' ORDER BY name");
1049+
assertQuery("SELECT longest_common_prefix(comment, comment) FROM orders ORDER BY orderkey LIMIT 10");
1050+
assertQuery("SELECT longest_common_prefix('', ''), longest_common_prefix('hello', 'hello world') FROM (VALUES 1)", "SELECT '', 'hello'");
1051+
1052+
// replace_first
1053+
assertQuery("SELECT replace_first(comment, 'the', 'THE') FROM orders ORDER BY orderkey LIMIT 10");
1054+
assertQuery("SELECT replace_first(name, 'A', 'X') FROM nation ORDER BY nationkey LIMIT 10");
1055+
assertQuery("SELECT replace_first('aaa', 'a', 'b') FROM (VALUES 1)", "SELECT 'baa'");
1056+
assertQuery("SELECT replace_first(comment, ' ', '') FROM orders ORDER BY orderkey LIMIT 10");
10411057
}
10421058

10431059
@Test

0 commit comments

Comments
 (0)