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

tkalkirill pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 85e7740a7b6 IGNITE-29081 SQL Calcite: Support custom Java types in UDF 
and UDTF parameters and results (#13622)
85e7740a7b6 is described below

commit 85e7740a7b6607cb036eec5e76550392b359c067
Author: Kirill Tkalenko <[email protected]>
AuthorDate: Wed Sep 30 19:44:22 2026 +0300

    IGNITE-29081 SQL Calcite: Support custom Java types in UDF and UDTF 
parameters and results (#13622)
---
 .../query/calcite/exec/exp/ConverterUtils.java     |  13 +-
 .../calcite/exec/exp/IgniteFunctionParameter.java  |   9 +-
 .../calcite/exec/exp/IgniteTableFunction.java      |  15 +-
 .../query/calcite/type/IgniteTypeFactory.java      |  36 +-
 .../exec/exp/IgniteFunctionParameterTest.java      |  59 ++++
 .../UserDefinedFunctionsIntegrationTest.java       | 375 ++++++++++++++++++++-
 .../apache/ignite/testsuites/UtilTestSuite.java    |   2 +
 7 files changed, 484 insertions(+), 25 deletions(-)

diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ConverterUtils.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ConverterUtils.java
index 8dc7224dcea..55dc1c71173 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ConverterUtils.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ConverterUtils.java
@@ -540,13 +540,16 @@ public class ConverterUtils {
         return list;
     }
 
-    /**
-     * Handles decimal type specifically with explicit type conversion.
-     */
+    /** Converts an argument to its Java parameter type, handling decimals 
separately. */
     private static Expression convertAssignableType(Expression argument, Type 
targetType) {
-        if (targetType != BigDecimal.class || 
!Types.needTypeCast(argument.getType(), targetType))
+        // Java method calls can box primitives when the parameter accepts the 
boxed type.
+        if (Types.isAssignableFrom(targetType, argument.getType())
+            || Types.isAssignableFrom(targetType, 
Primitive.box(argument.getType())))
             return argument;
 
-        return convertToDecimal(argument, 
Commons.typeFactory().createSqlType(SqlTypeName.DECIMAL));
+        if (targetType == BigDecimal.class)
+            return convertToDecimal(argument, 
Commons.typeFactory().createSqlType(SqlTypeName.DECIMAL));
+
+        return convert(argument, targetType);
     }
 }
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteFunctionParameter.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteFunctionParameter.java
index f311b192ffb..febf2577bf2 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteFunctionParameter.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteFunctionParameter.java
@@ -16,10 +16,12 @@
  */
 package org.apache.ignite.internal.processors.query.calcite.exec.exp;
 
-import org.apache.calcite.adapter.java.JavaTypeFactory;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.schema.FunctionParameter;
+import org.apache.calcite.sql.type.SqlTypeName;
+import 
org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory;
+import org.apache.ignite.internal.processors.query.calcite.type.OtherType;
 
 /** Function parameter that exposes its SQL type to validation. */
 class IgniteFunctionParameter implements FunctionParameter {
@@ -44,7 +46,10 @@ class IgniteFunctionParameter implements FunctionParameter {
     /** {@inheritDoc} */
     @Override public RelDataType getType(RelDataTypeFactory typeFactory) {
         // Normalize UDF metadata without losing Java types used to convert 
query results.
-        return 
((JavaTypeFactory)typeFactory).toSql(delegate.getType(typeFactory));
+        RelDataType type = IgniteTypeFactory.toSql(typeFactory, 
delegate.getType(typeFactory));
+
+        // Use Ignite's generic type to support arbitrary values and prevent 
inferring a record from a Java object.
+        return type.getSqlTypeName() == SqlTypeName.OTHER ? new 
OtherType(type.isNullable()) : type;
     }
 
     /** {@inheritDoc} */
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteTableFunction.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteTableFunction.java
index e9ece1ee9a7..d668f6d9c93 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteTableFunction.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteTableFunction.java
@@ -21,6 +21,7 @@ import java.lang.reflect.Type;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.apache.calcite.adapter.enumerable.NullPolicy;
@@ -28,8 +29,10 @@ import org.apache.calcite.adapter.java.JavaTypeFactory;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.schema.TableFunction;
+import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.ignite.cache.query.annotations.QuerySqlTableFunction;
 import org.apache.ignite.internal.processors.query.IgniteSQLException;
+import org.apache.ignite.internal.processors.query.calcite.type.OtherType;
 import org.apache.ignite.internal.util.typedef.F;
 
 /**
@@ -80,7 +83,7 @@ public class IgniteTableFunction extends 
IgniteReflectiveFunctionBase implements
     @Override public RelDataType getRowType(RelDataTypeFactory typeFactory, 
List<?> arguments) {
         JavaTypeFactory tf = (JavaTypeFactory)typeFactory;
 
-        List<RelDataType> converted = Stream.of(colTypes).map(cl -> 
tf.toSql(tf.createType(cl))).collect(Collectors.toList());
+        List<RelDataType> converted = Stream.of(colTypes).map(cl -> 
columnType(tf, cl)).collect(Collectors.toList());
 
         return typeFactory.createStructType(converted, colNames);
     }
@@ -100,6 +103,16 @@ public class IgniteTableFunction extends 
IgniteReflectiveFunctionBase implements
         return Iterable.class;
     }
 
+    /** Resolves collection types without treating user-defined classes as 
records. */
+    private static RelDataType columnType(JavaTypeFactory tf, Class<?> cls) {
+        RelDataType type = cls.isArray() || List.class.isAssignableFrom(cls) 
|| Map.class.isAssignableFrom(cls)
+            ? tf.createType(cls)
+            : tf.createJavaType(cls);
+
+        RelDataType sqlType = tf.toSql(type);
+        return sqlType.getSqlTypeName() == SqlTypeName.OTHER ? new 
OtherType(sqlType.isNullable()) : sqlType;
+    }
+
     /** Validates the parameters and throws an exception if it finds an 
incorrect parameter. */
     private static void validate(Method mtd, Class<?>[] colTypes, String[] 
colNames) {
         if (F.isEmpty(colTypes))
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java
index 59d19b9817d..f1d54c1ce48 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/type/IgniteTypeFactory.java
@@ -36,6 +36,7 @@ import org.apache.calcite.avatica.util.ByteString;
 import org.apache.calcite.avatica.util.TimeUnit;
 import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
 import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.rel.type.RelDataTypeSystem;
 import org.apache.calcite.sql.SqlIntervalQualifier;
 import org.apache.calcite.sql.SqlUtil;
@@ -288,30 +289,41 @@ public class IgniteTypeFactory extends 
JavaTypeFactoryImpl {
 
     /** {@inheritDoc} */
     @Override public RelDataType toSql(RelDataType type) {
+        if (type instanceof JavaType) {
+            RelDataType customType = 
createCustomType(((JavaType)type).getJavaClass());
+
+            if (customType != null)
+                return customType;
+        }
+
+        return toSql(this, type);
+    }
+
+    /** Converts Java types, including Java time types, to SQL types using the 
supplied factory. */
+    public static RelDataType toSql(RelDataTypeFactory typeFactory, 
RelDataType type) {
         if (type instanceof JavaType) {
             Class<?> clazz = ((JavaType)type).getJavaClass();
+            RelDataType sqlType;
 
             if (clazz == Duration.class)
-                return 
createTypeWithNullability(createSqlIntervalType(INTERVAL_QUALIFIER_DAY_TIME), 
true);
+                sqlType = 
typeFactory.createSqlIntervalType(INTERVAL_QUALIFIER_DAY_TIME);
             else if (clazz == Period.class)
-                return 
createTypeWithNullability(createSqlIntervalType(INTERVAL_QUALIFIER_YEAR_MONTH), 
true);
+                sqlType = 
typeFactory.createSqlIntervalType(INTERVAL_QUALIFIER_YEAR_MONTH);
             else if (clazz == LocalDateTime.class)
-                return 
createTypeWithNullability(createSqlType(SqlTypeName.TIMESTAMP), true);
+                sqlType = typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
             else if (clazz == LocalDate.class)
-                return 
createTypeWithNullability(createSqlType(SqlTypeName.DATE), true);
+                sqlType = typeFactory.createSqlType(SqlTypeName.DATE);
             else if (clazz == LocalTime.class)
-                return 
createTypeWithNullability(createSqlType(SqlTypeName.TIME), true);
+                sqlType = typeFactory.createSqlType(SqlTypeName.TIME);
             else if (clazz == UUID.class)
-                return 
createTypeWithNullability(createSqlType(SqlTypeName.UUID), true);
-            else {
-                RelDataType relType = createCustomType(clazz);
+                sqlType = typeFactory.createSqlType(SqlTypeName.UUID);
+            else
+                return JavaTypeFactoryImpl.toSql(typeFactory, type);
 
-                if (relType != null)
-                    return relType;
-            }
+            return typeFactory.createTypeWithNullability(sqlType, true);
         }
 
-        return super.toSql(type);
+        return JavaTypeFactoryImpl.toSql(typeFactory, type);
     }
 
     /** @return Custom type by storage type. {@code Null} if custom type not 
found. */
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteFunctionParameterTest.java
 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteFunctionParameterTest.java
new file mode 100644
index 00000000000..dd8500de24e
--- /dev/null
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteFunctionParameterTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.ignite.internal.processors.query.calcite.exec.exp;
+
+import java.time.LocalDateTime;
+import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.rel.type.RelDataTypeSystemImpl;
+import org.apache.calcite.schema.FunctionParameter;
+import org.apache.calcite.schema.impl.ReflectiveFunctionBase;
+import org.apache.calcite.sql.type.SqlTypeName;
+import 
org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/** Tests SQL types exposed by user-defined function parameters. */
+public class IgniteFunctionParameterTest {
+    /** */
+    @Test
+    public void testUsesProvidedTypeSystem() {
+        RelDataTypeSystem typeSys = new RelDataTypeSystemImpl() {
+            @Override public int getDefaultPrecision(SqlTypeName typeName) {
+                return typeName == SqlTypeName.TIMESTAMP ? 2 : 
super.getDefaultPrecision(typeName);
+            }
+        };
+
+        FunctionParameter param = new IgniteFunctionParameter(
+            ReflectiveFunctionBase.builder().add(LocalDateTime.class, 
"ts").build().get(0));
+
+        for (RelDataTypeFactory factory : new RelDataTypeFactory[] {
+            new JavaTypeFactoryImpl(typeSys), new IgniteTypeFactory(typeSys)
+        }) {
+            RelDataType type = param.getType(factory);
+
+            assertEquals(SqlTypeName.TIMESTAMP, type.getSqlTypeName());
+            assertEquals(2, type.getPrecision());
+            assertTrue(type.isNullable());
+        }
+    }
+}
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java
 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java
index 4cc56827866..b6a445bdfad 100644
--- 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java
@@ -27,17 +27,21 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.Period;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.TimeZone;
+import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import org.apache.calcite.schema.SchemaPlus;
 import org.apache.calcite.sql.validate.SqlValidatorException;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
@@ -507,6 +511,167 @@ public class UserDefinedFunctionsIntegrationTest extends 
AbstractBasicIntegratio
         assertQuery("SELECT udf.decimalToInt(5.3)").returns(5).check();
     }
 
+    /** */
+    @Test
+    public void testBinaryObjectFunctions() {
+        client.getOrCreateCache(new 
CacheConfiguration<>("binary-object-functions")
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(BinaryObjectFunctionsLibrary.class));
+
+        BinaryObject obj = client.binary().builder("TestBinaryObject")
+            .setField("value", 42, Integer.class)
+            .build();
+
+        Consumer<List<List<?>>> resultChecker = rows -> {
+            assertEquals(1, rows.size());
+            assertEquals(1, rows.get(0).size());
+            assertTrue(rows.get(0).get(0) instanceof BinaryObject);
+            assertEquals(Integer.valueOf(42), 
((BinaryObject)rows.get(0).get(0)).field("value"));
+        };
+
+        assertQuery("SELECT binaryObjectEcho(?)")
+            .withParams(obj)
+            .withResultChecker(resultChecker)
+            .check();
+
+        assertQuery("SELECT * FROM binaryObjectTable(?)")
+            .withParams(obj)
+            .withResultChecker(resultChecker)
+            .check();
+    }
+
+    /** */
+    @Test
+    public void testPrimitiveFunctions() {
+        client.getOrCreateCache(new CacheConfiguration<>("primitive-functions")
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(PrimitiveFunctionsLibrary.class));
+
+        Object[] values = {true, (byte)1, (short)2, 3, 4L, 5.0f, 6.0d};
+
+        assertQuery("SELECT checkPrimitiveTypes(?, ?, ?, ?, ?, ?, ?)")
+            .withParams(values)
+            .returns(true)
+            .check();
+
+        assertQuery("SELECT primitiveBoolean(), primitiveByte(), 
primitiveShort(), primitiveInt(), "
+            + "primitiveLong(), primitiveFloat(), primitiveDouble()")
+            .returns(true, (byte)1, (short)2, 3, 4L, 5.0f, 6.0d)
+            .check();
+
+        assertQuery("SELECT * FROM primitiveTable(?, ?, ?, ?, ?, ?, ?)")
+            .withParams(values)
+            .returns(true, (byte)1, (short)2, 3, 4L, 5.0f, 6.0d)
+            .check();
+    }
+
+    /** */
+    @Test
+    public void testBoxedFunctionArguments() {
+        client.getOrCreateCache(new 
CacheConfiguration<>("boxed-argument-functions")
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(BoxedArgumentsFunctionsLibrary.class));
+
+        String[] literals = {"-1", "CAST(-1 AS BIGINT)", "CAST(-1 AS REAL)", 
"CAST(-1 AS DOUBLE)"};
+        Object[] values = {-1, -1L, -1.0f, -1.0d};
+
+        for (int i = 0; i < literals.length; i++) {
+            String args = String.join(", ", Collections.nCopies(3, 
literals[i]));
+            Object val = values[i];
+
+            assertQuery("SELECT checkBoxedArguments(" + args + 
")").returns(true).check();
+            assertQuery("SELECT checkBoxedArguments(?, ?, ?)").withParams(val, 
val, val).returns(true).check();
+
+            assertQuery("SELECT * FROM boxedArgumentsTable(" + args + 
")").returns(val, val, val).check();
+            assertQuery("SELECT * FROM boxedArgumentsTable(?, ?, ?)")
+                .withParams(val, val, val)
+                .returns(val, val, val)
+                .check();
+        }
+    }
+
+    /** */
+    @Test
+    public void testCustomTypeFunctions() {
+        client.getOrCreateCache(new 
CacheConfiguration<>("custom-type-functions")
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(CustomTypeFunctionsLibrary.class));
+
+        Employer obj = new Employer("Igor", 42.0d);
+        Consumer<List<List<?>>> resultChecker = rows -> {
+            assertEquals(1, rows.size());
+            assertEquals(1, rows.get(0).size());
+            assertTrue(rows.get(0).get(0) instanceof Employer);
+            assertEquals(obj, rows.get(0).get(0));
+        };
+
+        assertQuery("SELECT customTypeEcho(?)")
+            .withParams(obj)
+            .withResultChecker(resultChecker)
+            .check();
+
+        assertQuery("SELECT * FROM customTypeTable(?)")
+            .withParams(obj)
+            .withResultChecker(resultChecker)
+            .check();
+    }
+
+    /** */
+    @Test
+    public void testCustomTypeTableFunctionCoalesce() {
+        client.getOrCreateCache(new 
CacheConfiguration<>("custom-type-coalesce-functions")
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(CustomTypeFunctionsLibrary.class));
+
+        Employer obj = new Employer("Igor", 42.0d);
+        Employer fallback = new Employer("Oleg", 43.0d);
+
+        for (Employer val : new Employer[] {obj, null}) {
+            assertQuery("SELECT COALESCE(obj, obj) FROM customTypeTable(?)")
+                .withParams(val)
+                .returns(val)
+                .check();
+
+            assertQuery("SELECT COALESCE(t1.obj, t2.obj) "
+                + "FROM customTypeTable(?) t1 CROSS JOIN customTypeTable(?) 
t2")
+                .withParams(val, fallback)
+                .returns(val == null ? fallback : val)
+                .check();
+        }
+    }
+
+    /** */
+    @Test
+    public void testArrayListTableFunctionResult() {
+        client.getOrCreateCache(new 
CacheConfiguration<>("array-list-table-functions")
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(CollectionFunctionsLibrary.class));
+
+        assertQuery("SELECT val FROM arrayListTable()")
+            .returns(Arrays.asList(1, 2))
+            .check();
+
+        assertQuery("SELECT CARDINALITY(val), val[1], val[2] FROM 
arrayListTable()")
+            .returns(2, 1, 2)
+            .check();
+    }
+
+    /** */
+    @Test
+    public void testHashMapTableFunctionResult() {
+        client.getOrCreateCache(new 
CacheConfiguration<>("hash-map-table-functions")
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(CollectionFunctionsLibrary.class));
+
+        assertQuery("SELECT val FROM hashMapTable()")
+            .returns(F.asMap("first", 10, "second", 20))
+            .check();
+
+        assertQuery("SELECT CARDINALITY(val), val['first'], val['second'], 
val['missing'] FROM hashMapTable()")
+            .returns(2, 10, 20, null)
+            .check();
+    }
+
     /** */
     @Test
     public void testObjectTableFunctionResult() {
@@ -514,9 +679,13 @@ public class UserDefinedFunctionsIntegrationTest extends 
AbstractBasicIntegratio
             .setSqlSchema("PUBLIC")
             .setSqlFunctionClasses(CustomTypeFunctionsLibrary.class));
 
-        Object[] exp = temporalValues();
+        BinaryObject binaryObj = 
client.binary().builder("TestObjectTableBinaryObject")
+            .setField("value", 42, Integer.class)
+            .build();
+        Object[] exp = objectValues(binaryObj);
 
-        assertQuery("SELECT * FROM objectTableValues()")
+        assertQuery("SELECT * FROM objectTableValues(?)")
+            .withParams(binaryObj)
             .withResultChecker(rows -> {
                 assertEquals(1, rows.size());
                 assertEquals(exp.length, rows.get(0).size());
@@ -884,6 +1053,32 @@ public class UserDefinedFunctionsIntegrationTest extends 
AbstractBasicIntegratio
         };
     }
 
+    /** */
+    private static Object[] objectValues(BinaryObject binaryObj) {
+        Object[] temporalValues = temporalValues();
+
+        return new Object[] {
+            true,
+            (byte)1,
+            (short)2,
+            3,
+            4L,
+            5.0f,
+            6.0d,
+            temporalValues[0],
+            temporalValues[1],
+            temporalValues[2],
+            temporalValues[3],
+            temporalValues[4],
+            temporalValues[5],
+            temporalValues[6],
+            temporalValues[7],
+            temporalValues[8],
+            new Employer("Igor", 42.0d),
+            binaryObj
+        };
+    }
+
     /** */
     @SuppressWarnings("ThrowableNotThrown")
     private void assertThrows(String sql) {
@@ -1307,6 +1502,131 @@ public class UserDefinedFunctionsIntegrationTest 
extends AbstractBasicIntegratio
             "with the same name and parameters is already registered").build();
     }
 
+    /** */
+    public static class BinaryObjectFunctionsLibrary {
+        /** */
+        @QuerySqlFunction
+        public static BinaryObject binaryObjectEcho(BinaryObject obj) {
+            return obj;
+        }
+
+        /** */
+        @QuerySqlTableFunction(columnTypes = {BinaryObject.class}, columnNames 
= {"OBJ"})
+        public static Iterable<Object[]> binaryObjectTable(BinaryObject obj) {
+            return Collections.singletonList(new Object[] {obj});
+        }
+    }
+
+    /** */
+    public static class PrimitiveFunctionsLibrary {
+        /** */
+        @QuerySqlFunction
+        public static boolean checkPrimitiveTypes(
+            boolean booleanVal,
+            byte byteVal,
+            short shortVal,
+            int intVal,
+            long longVal,
+            float floatVal,
+            double doubleVal
+        ) {
+            return booleanVal && byteVal == 1 && shortVal == 2 && intVal == 3 
&& longVal == 4
+                && floatVal == 5.0f && doubleVal == 6.0d;
+        }
+
+        /** */
+        @QuerySqlFunction
+        public static boolean primitiveBoolean() {
+            return true;
+        }
+
+        /** */
+        @QuerySqlFunction
+        public static byte primitiveByte() {
+            return 1;
+        }
+
+        /** */
+        @QuerySqlFunction
+        public static short primitiveShort() {
+            return 2;
+        }
+
+        /** */
+        @QuerySqlFunction
+        public static int primitiveInt() {
+            return 3;
+        }
+
+        /** */
+        @QuerySqlFunction
+        public static long primitiveLong() {
+            return 4;
+        }
+
+        /** */
+        @QuerySqlFunction
+        public static float primitiveFloat() {
+            return 5.0f;
+        }
+
+        /** */
+        @QuerySqlFunction
+        public static double primitiveDouble() {
+            return 6.0d;
+        }
+
+        /** */
+        @QuerySqlTableFunction(
+            columnTypes = {
+                boolean.class,
+                byte.class,
+                short.class,
+                int.class,
+                long.class,
+                float.class,
+                double.class
+            },
+            columnNames = {
+                "BOOLEAN_VALUE",
+                "BYTE_VALUE",
+                "SHORT_VALUE",
+                "INT_VALUE",
+                "LONG_VALUE",
+                "FLOAT_VALUE",
+                "DOUBLE_VALUE"
+            }
+        )
+        public static Iterable<Object[]> primitiveTable(
+            boolean booleanVal,
+            byte byteVal,
+            short shortVal,
+            int intVal,
+            long longVal,
+            float floatVal,
+            double doubleVal
+        ) {
+            return Collections.singletonList(new Object[] {
+                booleanVal, byteVal, shortVal, intVal, longVal, floatVal, 
doubleVal
+            });
+        }
+    }
+
+    /** */
+    public static class BoxedArgumentsFunctionsLibrary {
+        /** */
+        @QuerySqlFunction
+        public static boolean checkBoxedArguments(Object obj, Number num, 
Serializable serializable) {
+            return obj.equals(num) && obj.equals(serializable);
+        }
+
+        /** */
+        @QuerySqlTableFunction(columnTypes = {Object.class, Object.class, 
Object.class}, columnNames = {"O", "N", "S"})
+        public static Iterable<Object[]> boxedArgumentsTable(Object obj, 
Number num, Serializable serializable) {
+            return Collections.singletonList(new Object[] {obj, num, 
serializable});
+        }
+    }
+
     /** */
     public static class SerializableFunctionsLibrary {
         /** */
@@ -1316,11 +1636,47 @@ public class UserDefinedFunctionsIntegrationTest 
extends AbstractBasicIntegratio
         }
     }
 
+    /** */
+    public static class CollectionFunctionsLibrary {
+        /** */
+        @QuerySqlTableFunction(columnTypes = {ArrayList.class}, columnNames = 
{"VAL"})
+        public static Iterable<Object[]> arrayListTable() {
+            return Collections.singletonList(new Object[] {new 
ArrayList<>(Arrays.asList(1, 2))});
+        }
+
+        /** */
+        @QuerySqlTableFunction(columnTypes = {HashMap.class}, columnNames = 
{"VAL"})
+        public static Iterable<Object[]> hashMapTable() {
+            return Collections.singletonList(new Object[] {new 
HashMap<>(F.asMap("first", 10, "second", 20))});
+        }
+    }
+
     /** */
     public static class CustomTypeFunctionsLibrary {
+        /** */
+        @QuerySqlFunction
+        public static Employer customTypeEcho(Employer obj) {
+            return obj;
+        }
+
+        /** */
+        @QuerySqlTableFunction(columnTypes = {Employer.class}, columnNames = 
{"OBJ"})
+        public static Iterable<Object[]> customTypeTable(Employer obj) {
+            return Collections.singletonList(new Object[] {obj});
+        }
+
         /** */
         @QuerySqlTableFunction(
             columnTypes = {
+                Object.class,
+                Object.class,
+                Object.class,
+                Object.class,
+                Object.class,
+                Object.class,
+                Object.class,
+                Object.class,
+                Object.class,
                 Object.class,
                 Object.class,
                 Object.class,
@@ -1332,6 +1688,13 @@ public class UserDefinedFunctionsIntegrationTest extends 
AbstractBasicIntegratio
                 Object.class
             },
             columnNames = {
+                "BOOLEAN_VALUE",
+                "BYTE_VALUE",
+                "SHORT_VALUE",
+                "INT_VALUE",
+                "LONG_VALUE",
+                "FLOAT_VALUE",
+                "DOUBLE_VALUE",
                 "UTIL_DATE",
                 "SQL_DATE",
                 "SQL_TIME",
@@ -1340,11 +1703,13 @@ public class UserDefinedFunctionsIntegrationTest 
extends AbstractBasicIntegratio
                 "LOCAL_TIME",
                 "LOCAL_TIMESTAMP",
                 "DURATION_VALUE",
-                "PERIOD_VALUE"
+                "PERIOD_VALUE",
+                "CUSTOM_VALUE",
+                "BINARY_OBJECT_VALUE"
             }
         )
-        public static Iterable<Object[]> objectTableValues() {
-            return Collections.singletonList(temporalValues());
+        public static Iterable<Object[]> objectTableValues(BinaryObject 
binaryObj) {
+            return Collections.singletonList(objectValues(binaryObj));
         }
     }
 
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java 
b/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java
index 0fb1a748d76..446bb0337ce 100644
--- 
a/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
 import org.apache.ignite.internal.processors.query.calcite.QueryCheckerTest;
 import 
org.apache.ignite.internal.processors.query.calcite.exec.ClosableIteratorsHolderTest;
 import 
org.apache.ignite.internal.processors.query.calcite.exec.KeyFilteringCursorTest;
+import 
org.apache.ignite.internal.processors.query.calcite.exec.exp.IgniteFunctionParameterTest;
 import 
org.apache.ignite.internal.processors.query.calcite.exec.exp.IgniteSqlFunctionsTest;
 import 
org.apache.ignite.internal.processors.query.calcite.exec.task.QueryBlockingTaskExecutorTest;
 import 
org.apache.ignite.internal.processors.query.calcite.exec.task.QueryTasksQueueTest;
@@ -43,6 +44,7 @@ import org.junit.platform.suite.api.Suite;
     QueryTasksQueueTest.class,
     OtherTypeTest.class,
     TypeUtilsTest.class,
+    IgniteFunctionParameterTest.class,
 })
 public class UtilTestSuite {
 }

Reply via email to