zstan commented on code in PR #3904:
URL: https://github.com/apache/calcite/pull/3904#discussion_r1711287643
##########
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:
no, it become less readable, i would prefer my current approach
--
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]