Skip to content

Commit 32df666

Browse files
committed
Add end-to-end tests for string functions: bit_length, longest_common_prefix, replace_first
1 parent b200d1f commit 32df666

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,24 @@ public void testStringFunctions()
989989
finally {
990990
dropTableIfExists(tmpTableName);
991991
}
992+
993+
// bit_length
994+
assertQuery("SELECT bit_length(name) FROM nation");
995+
assertQuery("SELECT bit_length(comment) FROM orders");
996+
assertQuery("SELECT bit_length('') FROM nation LIMIT 1", "SELECT 0");
997+
assertQuery("SELECT bit_length('hello') FROM nation LIMIT 1", "SELECT 40");
998+
999+
// longest_common_prefix
1000+
assertQuery("SELECT longest_common_prefix(name, 'UNITED') FROM nation WHERE name LIKE 'UNITED%'");
1001+
assertQuery("SELECT longest_common_prefix(comment, comment) FROM orders");
1002+
assertQuery("SELECT longest_common_prefix('', '') FROM nation LIMIT 1", "SELECT ''");
1003+
assertQuery("SELECT longest_common_prefix('hello', 'hello world') FROM nation LIMIT 1", "SELECT 'hello'");
1004+
1005+
// replace_first
1006+
assertQuery("SELECT replace_first(comment, 'the', 'THE') FROM orders");
1007+
assertQuery("SELECT replace_first(name, 'A', 'X') FROM nation");
1008+
assertQuery("SELECT replace_first('aaa', 'a', 'b') FROM nation LIMIT 1", "SELECT 'baa'");
1009+
assertQuery("SELECT replace_first(comment, ' ', '') FROM orders");
9921010
}
9931011

9941012
@Test

0 commit comments

Comments
 (0)