alex-plekhanov commented on code in PR #13569:
URL: https://github.com/apache/ignite/pull/13569#discussion_r4095255329
##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ReflectiveCallNotNullImplementor.java:
##########
@@ -66,6 +68,21 @@ public ReflectiveCallNotNullImplementor(Method method) {
callExpr = Expressions.call(target, method, translatedOperands);
}
+
+ if (TypeUtils.isConvertableType(method.getReturnType())) {
+ Type targetType =
translator.typeFactory.getJavaClass(call.getType());
+ Expression converted = ConverterUtils.toInternal(callExpr,
targetType);
+
+ if (converted != callExpr)
+ callExpr = converted;
+ else
+ callExpr = Expressions.convert_(
+ Expressions.call(TypeUtils.class, "toInternal",
translator.getRoot(), callExpr,
+ Expressions.constant(method.getReturnType())),
+ targetType
+ );
+ }
Review Comment:
Maybe it's worth to move this logic to new method
`ConverterUtils.toInternal(root, ...)` for symmetry with `fromInternal`
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java:
##########
@@ -492,6 +504,383 @@ public void testBigDecimalFunctionArgument() {
assertQuery("SELECT udf.decimalToInt(5.3)").returns(5).check();
}
+ /** */
+ @Test
+ public void testObjectTableFunctionResult() {
+ client.getOrCreateCache(new
CacheConfiguration<>("object-table-functions")
+ .setSqlSchema("PUBLIC")
+ .setSqlFunctionClasses(CustomTypeFunctionsLibrary.class));
+
+ Object[] exp = temporalValues();
+
+ assertQuery("SELECT * FROM objectTableValues()")
+ .withResultChecker(rows -> {
+ assertEquals(1, rows.size());
+ assertEquals(exp.length, rows.get(0).size());
+
+ for (int i = 0; i < exp.length; i++) {
+ Object actual = rows.get(0).get(i);
+
+ assertEquals("Unexpected value type at index " + i,
exp[i].getClass(), actual.getClass());
+ assertEquals("Unexpected value at index " + i, exp[i],
actual);
+ }
+ })
+ .check();
+ }
+
+ /** */
+ @Test
+ public void testSerializableTableFunctionResult() {
Review Comment:
What is so special in serialiazable values? Why check with Object type is
not enough?
##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableFunctionScan.java:
##########
@@ -58,14 +75,50 @@ private Row convertToRow(Object rowContainer) {
throw new IgniteSQLException("Unable to process table function
data: row type is neither Collection or Object[].");
Object[] rowArr = rowContainer.getClass() == Object[].class
- ? (Object[])rowContainer
+ ? ((Object[])rowContainer)
Review Comment:
Redundant parentheses
--
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]