This is an automated email from the ASF dual-hosted git repository.

zhenchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 452cff9c549ab4d7ea3c0679ed9c16b836bb7114
Author: Michal Stutzmann <[email protected]>
AuthorDate: Sat Aug 23 12:19:43 2025 +0200

    Add test
---
 .../apache/calcite/sql/type/FunctionSqlType.java   |  3 ++
 .../calcite/sql/type/FunctionSqlTypeTest.java      | 52 ++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/sql/type/FunctionSqlType.java 
b/core/src/main/java/org/apache/calcite/sql/type/FunctionSqlType.java
index 4633c3c88f..b71dbe1ef2 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/FunctionSqlType.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/FunctionSqlType.java
@@ -35,6 +35,9 @@ public FunctionSqlType(
       RelDataType parameterType, RelDataType returnType) {
     super(SqlTypeName.FUNCTION, true, null);
     this.parameterType = requireNonNull(parameterType, "parameterType");
+    if (!parameterType.isStruct()) {
+      throw new IllegalArgumentException("paramType must be a struct");
+    }
     this.returnType = requireNonNull(returnType, "returnType");
     computeDigest();
   }
diff --git 
a/core/src/test/java/org/apache/calcite/sql/type/FunctionSqlTypeTest.java 
b/core/src/test/java/org/apache/calcite/sql/type/FunctionSqlTypeTest.java
new file mode 100644
index 0000000000..3f780b3ecf
--- /dev/null
+++ b/core/src/test/java/org/apache/calcite/sql/type/FunctionSqlTypeTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql.type;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+
+import com.google.common.collect.ImmutableList;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests for {@link FunctionSqlType}.
+ */
+public class FunctionSqlTypeTest {
+  final RelDataTypeFactory sqlTypeFactory =
+      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
+
+  final RelDataType parameterType =
+      sqlTypeFactory.createStructType(
+          ImmutableList.of(sqlTypeFactory.createSqlType(SqlTypeName.BOOLEAN)),
+          ImmutableList.of("field1"));
+  final RelDataType returnType = 
sqlTypeFactory.createSqlType(SqlTypeName.BOOLEAN);
+  final FunctionSqlType functionSqlType =
+      new FunctionSqlType(parameterType, returnType);
+
+  @Test void testGetParamType() {
+    assertEquals(parameterType, functionSqlType.getParameterType());
+  }
+
+  @Test void testGetReturnType() {
+    assertEquals(returnType, functionSqlType.getReturnType());
+  }
+
+}

Reply via email to