zstan commented on code in PR #13543:
URL: https://github.com/apache/ignite/pull/13543#discussion_r3934838090


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableFunctionScan.java:
##########
@@ -58,14 +65,19 @@ 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).clone()
             : ((Collection<?>)rowContainer).toArray();
 
         if (rowArr.length != rowType.getFieldCount()) {
             throw new IgniteSQLException("Unable to process table function 
data: row length [" + rowArr.length
                 + "] doesn't match defined columns number [" + 
rowType.getFieldCount() + "].");
         }
 
+        for (int i = 0; i < rowArr.length; i++) {
+            if (!(rowType.getFieldList().get(i).getType() instanceof 
OtherType))

Review Comment:
   Also near passed on master and failed in current branch, seems regression: 
   
   ```
       @Test
       public void testCollectionColumnTableFunctions() {
           client.getOrCreateCache(new
               CacheConfiguration<>("collection-column-table-functions")
               .setSqlSchema("PUBLIC")
               .setSqlFunctionClasses(CollectionColumnFunctionsLibrary.class));
   
           // ArrayList column -> ARRAY.
           assertQuery("SELECT ID, CARDINALITY(VALS), VALS[1] FROM " +
               "listColumn()")
               .returns(1, 2, 10)
               .returns(2, 3, 30)
               .check();
   
           assertQuery("SELECT t.ID, v.VAL FROM listColumn() t, " +
               " UNNEST(t.VALS) v(VAL) ORDER BY t.ID, v.VAL")
               .returns(1, 10)
               .returns(1, 20)
               .returns(2, 30)
               .returns(2, 40)
               .returns(2, 50)
               .check();
   
           // String[] column -> MULTISET.
           assertQuery("SELECT ID, CARDINALITY(NAMES) FROM arrayColumn()")
               .returns(1, 1)
               .returns(2, 2)
               .check();
   
           assertQuery("SELECT t.ID, n.NAME FROM arrayColumn() t, " +
               " UNNEST(t.NAMES) n(NAME) ORDER BY t.ID, n.NAME")
               .returns(1, "a")
               .returns(2, "b")
               .returns(2, "c")
               .check();
       }
   
       /** */
       public static final class CollectionColumnFunctionsLibrary {
           /** */
           private CollectionColumnFunctionsLibrary() {
               // No-op.
           }
   
           /** Returns rows with a {@link List}-typed column. */
           @QuerySqlTableFunction(columnTypes = {int.class, ArrayList.class},
               columnNames = {"ID", "VALS"})
           public static Iterable<Collection<?>> listColumn() {
               return Arrays.asList(
                   Arrays.asList(1, new ArrayList<>(Arrays.asList(10, 20))),
                   Arrays.asList(2, new ArrayList<>(Arrays.asList(30, 40,
                       50)))
               );
           }
   
           /** Returns rows with an array-typed column. */
           @QuerySqlTableFunction(columnTypes = {int.class, String[].class},
               columnNames = {"ID", "NAMES"})
           public static Iterable<Collection<?>> arrayColumn() {
               return Arrays.asList(
                   Arrays.asList(1, Arrays.asList("a")),
                   Arrays.asList(2, Arrays.asList("b", "c"))
               );
           }
       }
   ```



-- 
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]

Reply via email to