mihaibudiu commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1434613012


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,44 @@ private void testCurrentDateFunc(Pair<String, 
Hook.Closeable> pair) {
     f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
   }
 
-  @Test void testStartsWithFunction() {
+  /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+  @ParameterizedTest(name = "{0}")
+  @MethodSource("startsWithAliases")
+  void testStartsWithFunction2(FunctionAlias functionAlias) {
     final SqlOperatorFixture f0 = fixture();
-    f0.setFor(SqlLibraryOperators.STARTS_WITH);
+    final SqlFunction function = functionAlias.function;
+    f0.setFor(function);
+    final String alias = functionAlias.alias;
     final Consumer<SqlOperatorFixture> consumer = f -> {
-      f.checkBoolean("starts_with('12345', '123')", true);
-      f.checkBoolean("starts_with('12345', '1243')", false);
-      f.checkBoolean("starts_with(x'11', x'11')", true);
-      f.checkBoolean("starts_with(x'112211', x'33')", false);
-      f.checkFails("^starts_with('aabbcc', x'aa')^",
-          "Cannot apply 'STARTS_WITH' to arguments of type "
-              + "'STARTS_WITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. 
Supported "
-              + "form\\(s\\): 'STARTS_WITH\\(<STRING>, <STRING>\\)'",
+      f.checkBoolean(alias + "('12345', '123')", true);

Review Comment:
   Another possible suggestion is to have the alias implement a "rewrite" 
method which rewrites a specific template. Then you can write tests like 
`f.checkBoolean(alias.rewrite("%function%('12345', '1234')"))`. But I don't 
know if the readability of the test improves much.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to