liuyongvs commented on code in PR #3198:
URL: https://github.com/apache/calcite/pull/3198#discussion_r1193148196
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5336,6 +5336,25 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkNull("array_distinct(null)");
}
+ /** Tests {@code ARRAY_REPEAT} function from Spark. */
+ @Test void testArrayRepeatFunc() {
+ final SqlOperatorFixture f0 = fixture();
+ f0.setFor(SqlLibraryOperators.ARRAY_REPEAT);
+ f0.checkFails("^array_repeat(1, 2)^",
+ "No match found for function signature ARRAY_REPEAT\\(<NUMERIC>,
<NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK);
+ f.checkScalar("array_repeat(1, 2)", "[1, 1]",
+ "INTEGER NOT NULL ARRAY NOT NULL");
+ f.checkScalar("array_repeat(array[1, 2], 2)", "[[1, 2], [1, 2]]",
+ "INTEGER NOT NULL ARRAY NOT NULL ARRAY NOT NULL");
+ f.checkScalar("array_repeat(map[1, 'a', 2, 'b'], 2)", "[{1=a, 2=b}, {1=a,
2=b}]",
+ "(INTEGER NOT NULL, CHAR(1) NOT NULL) MAP NOT NULL ARRAY NOT NULL");
+ f.checkScalar("array_repeat(cast(null as integer), 2)", "[null, null]",
+ "INTEGER ARRAY NOT NULL");
Review Comment:
why? it only be nullable when the element is null.
```
case class ArrayRepeat(left: Expression, right: Expression)
extends BinaryExpression with ExpectsInputTypes {
override def nullable: Boolean = right.nullable
```
--
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]