This is an automated email from the ASF dual-hosted git repository.
mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 1cfb72e905 [CALCITE-6347] ARRAY_REPEAT with a string argument causes a
compiler crash
1cfb72e905 is described below
commit 1cfb72e905d0da9182aaf0e05496dbf5e77cf5bd
Author: Mihai Budiu <[email protected]>
AuthorDate: Mon Apr 1 11:36:42 2024 -0700
[CALCITE-6347] ARRAY_REPEAT with a string argument causes a compiler crash
Signed-off-by: Mihai Budiu <[email protected]>
---
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java | 2 +-
core/src/main/java/org/apache/calcite/util/BuiltInMethod.java | 2 +-
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java | 2 ++
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index 7ba962eaca..54a9571907 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -5285,7 +5285,7 @@ public class SqlFunctions {
}
/** Support the ARRAY_REPEAT function. */
- public static @Nullable List<Object> repeat(Object element, Object count) {
+ public static @Nullable List<Object> arrayRepeat(Object element, Object
count) {
if (count == null) {
return null;
}
diff --git a/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
b/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
index 6280e11fdf..b25a29264f 100644
--- a/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
+++ b/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java
@@ -769,7 +769,7 @@ public enum BuiltInMethod {
ARRAY_POSITION(SqlFunctions.class, "arrayPosition", List.class,
Object.class),
ARRAY_PREPEND(SqlFunctions.class, "arrayPrepend", List.class, Object.class),
ARRAY_REMOVE(SqlFunctions.class, "arrayRemove", List.class, Object.class),
- ARRAY_REPEAT(SqlFunctions.class, "repeat", Object.class, Integer.class),
+ ARRAY_REPEAT(SqlFunctions.class, "arrayRepeat", Object.class, Integer.class),
ARRAY_EXCEPT(SqlFunctions.class, "arrayExcept", List.class, List.class),
ARRAY_INSERT(SqlFunctions.class, "arrayInsert", List.class, Integer.class,
Object.class),
ARRAY_INTERSECT(SqlFunctions.class, "arrayIntersect", List.class,
List.class),
diff --git a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
index 69523906db..eb7e087398 100644
--- a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
+++ b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
@@ -6784,6 +6784,8 @@ public class SqlOperatorTest {
"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]",
+ "CHAR(1) NOT NULL ARRAY NOT NULL");
f.checkScalar("array_repeat(1, 2)", "[1, 1]",
"INTEGER NOT NULL ARRAY NOT NULL");
f.checkScalar("array_repeat(1, -2)", "[]",