caicancai commented on code in PR #3904:
URL: https://github.com/apache/calcite/pull/3904#discussion_r1710918810


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1076,15 +1076,39 @@ public static String substring(String c, int s, int l) {
   }
 
   public static String substring(String c, int s, long l) {
-    return substring(c, s, clamp(l));
+    if (s < 0) {
+      if (l > 0 && l + s > 0) {
+        l += s;
+        return substring(c, 0, l);
+      }
+    }
+    int l0 = clamp(l);
+    return SqlFunctions.substring(c, s, l0);
   }
 
   public static String substring(String c, long s, int l) {
-    return substring(c, clamp(s), l);
+    if (s < 0) {

Review Comment:
   `return s < 0 ? (s += l) > 0 ? substring(c, 0, s) : "" : /* your else case 
here */; `
   Better?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to