Skip to content

Commit b5155f9

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

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
@@ -989,6 +989,22 @@ public void testStringFunctions()
989989
finally {
990990
dropTableIfExists(tmpTableName);
991991
}
992+
993+
// bit_length
994+
assertQuery("SELECT bit_length(comment) FROM orders");
995+
assertQuery("SELECT bit_length(name) FROM nation");
996+
assertQuery("SELECT bit_length(shipmode) FROM lineitem");
997+
998+
// longest_common_prefix
999+
assertQuery("SELECT longest_common_prefix(name, 'UNITED') FROM nation WHERE name LIKE 'UNITED%' ORDER BY name");
1000+
assertQuery("SELECT longest_common_prefix(comment, comment) FROM orders ORDER BY orderkey LIMIT 10");
1001+
assertQuery("SELECT longest_common_prefix('', ''), longest_common_prefix('hello', 'hello world') FROM (VALUES 1)", "SELECT '', 'hello'");
1002+
1003+
// replace_first
1004+
assertQuery("SELECT replace_first(comment, 'the', 'THE') FROM orders ORDER BY orderkey LIMIT 10");
1005+
assertQuery("SELECT replace_first(name, 'A', 'X') FROM nation ORDER BY nationkey LIMIT 10");
1006+
assertQuery("SELECT replace_first('aaa', 'a', 'b') FROM (VALUES 1)", "SELECT 'baa'");
1007+
assertQuery("SELECT replace_first(comment, ' ', '') FROM orders ORDER BY orderkey LIMIT 10");
9921008
}
9931009

9941010
@Test

0 commit comments

Comments
 (0)