You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/04/01 06:13:45 UTC

[GitHub] [calcite] hsyuan commented on a change in pull request #1140: [CALCITE-2965] Implement string functions: REPEAT, SPACE, SOUNDEX, DI…

hsyuan commented on a change in pull request #1140: [CALCITE-2965] Implement string functions: REPEAT, SPACE, SOUNDEX, DI…
URL: https://github.com/apache/calcite/pull/1140#discussion_r270725772
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##########
 @@ -243,6 +249,49 @@ public static int ascii(String s) {
         ? 0 : s.codePointAt(0);
   }
 
+  /** SQL REPEAT(string, int) function. */
+  public static String repeat(String s, int n) {
+    if (n < 1) {
+      return "";
+    }
+    int len = s.length() * n;
+    StringBuilder buf = new StringBuilder(len);
+    for (int i = 0; i < n; i++) {
+      buf.append(s);
+    }
+    return buf.toString();
 
 Review comment:
   from L257~262, you can use Strings.repeat

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services