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/17 09:06:59 UTC

[GitHub] [calcite] pengzhiwei2018 commented on a change in pull request #1168: [CALCITE-3005] Implement string functions: LEFT, RIGHT

pengzhiwei2018 commented on a change in pull request #1168: [CALCITE-3005] Implement string functions: LEFT, RIGHT
URL: https://github.com/apache/calcite/pull/1168#discussion_r276142271
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##########
 @@ -243,6 +243,26 @@ public static int ascii(String s) {
         ? 0 : s.codePointAt(0);
   }
 
+  /** SQL LEFT(string, int) function. */
+  public static String left(String s, int n) {
+    if (n < 0) {
+      return "";
+    } else {
+      int len = s.length();
 
 Review comment:
   It is better to add a null-test for `s`.

----------------------------------------------------------------
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