NobiGo commented on code in PR #4194:
URL: https://github.com/apache/calcite/pull/4194#discussion_r1955433633
##########
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. */
Review Comment:
Be consistent with the descriptions of other functions.
`/** SQL {@ xxxxxx }. */`
##########
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)",
+ "[2, 3]",
+ "INTEGER NOT NULL ARRAY NOT NULL");
+ f.checkString("array_slice(array[1,null,3], 1, 2)",
+ "[null, 3]",
+ "INTEGER ARRAY NOT NULL");
+ f.checkString("array_slice(array[1,2,3], 1, 10)",
+ "[]",
+ "INTEGER NOT NULL ARRAY NOT NULL");
+ f.checkString("array_slice(array['a','b','c','d'], 1, 3)",
+ "[b, c, d]",
+ "CHAR(1) NOT NULL ARRAY NOT NULL");
+ f.checkString("array_slice(array[null,null,null], 1, 2)",
Review Comment:
What happens if start is NULL or length is NULL?
--
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]