ILuffZhe commented on code in PR #4194:
URL: https://github.com/apache/calcite/pull/4194#discussion_r1955404153


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -6524,6 +6524,15 @@ public static List reverse(List list) {
     return list;
   }
 
+  /** Support the ARRAY_SLICE function. */
+  public static List arraySlice(List list, int start, int length) {
+    // return empty list if start/length are out of range of the array

Review Comment:
   How about "... if start + length exceeds the boundary of the array"?



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8204,6 +8204,33 @@ void checkRegexpExtract(SqlOperatorFixture f0, 
FunctionAlias functionAlias) {
         "DECIMAL(19, 0)");
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6831";>[CALCITE-6831]
+   * Add ARRAR_SLICE function (enabled in Hive library)</a>. */
+  @Test void testArraySlice() {
+    SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.ARRAY_SLICE);
+    final List<SqlLibrary> libraries =
+        ImmutableList.of(SqlLibrary.HIVE);
+    final Consumer<SqlOperatorFixture> consumer = f -> {
+      f.checkString("array_slice(array[1,2,3], 1, 2)",

Review Comment:
   What happens if start is a negative number?



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