tkalkirill commented on code in PR #13225:
URL: https://github.com/apache/ignite/pull/13225#discussion_r3861069951


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableFunctionScan.java:
##########
@@ -36,34 +37,57 @@ public class TableFunctionScan<Row> implements 
Iterable<Row> {
     /** */
     private final RowFactory<Row> rowFactory;
 
+    /** */
+    Function<Object, Object> binaryMarshaller;
+
+    /** */
+    private static final String ERR_SIZE_TEMPLATE = "Unable to process table 
function data: row length [%d]" +
+        " doesn't match defined columns number [%d].";
+
     /** */
     public TableFunctionScan(
         RelDataType rowType,
         Supplier<Iterable<?>> dataSupplier,
-        RowFactory<Row> rowFactory
+        RowFactory<Row> rowFactory,
+        Function<Object, Object> marshaller
     ) {
         this.rowType = rowType;
         this.dataSupplier = dataSupplier;
         this.rowFactory = rowFactory;
+        binaryMarshaller = marshaller;
     }
 
     /** {@inheritDoc} */
     @Override public Iterator<Row> iterator() {
         return F.iterator(dataSupplier.get(), this::convertToRow, true);
     }
 
+    /** */
+    private static void rowSizeChecker(int rowSize, int fldCount) {
+        if (rowSize != fldCount)
+            throw new IgniteSQLException(ERR_SIZE_TEMPLATE.formatted(rowSize, 
fldCount));
+    }
+
     /** */
     private Row convertToRow(Object rowContainer) {
         if (rowContainer.getClass() != Object[].class && 
!Collection.class.isAssignableFrom(rowContainer.getClass()))
             throw new IgniteSQLException("Unable to process table function 
data: row type is neither Collection or Object[].");
 
-        Object[] rowArr = rowContainer.getClass() == Object[].class
-            ? (Object[])rowContainer
-            : ((Collection<?>)rowContainer).toArray();
+        if (rowContainer instanceof Object[])
+            rowSizeChecker(((Object[])rowContainer).length, 
rowType.getFieldCount());
+        else
+            rowSizeChecker(((Collection<?>)rowContainer).size(), 
rowType.getFieldCount());
 
-        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() + "].");
+        Object[] rowArr;

Review Comment:
   I don’t think this is a valid justification for the change. Aligning the 
internal row-container representation of `TableScan` and `TableFunctionScan` is 
one thing; unconditionally converting every value returned by a table function 
to `BinaryObject` is another. The latter changes the observable result 
contract: a table function that previously returned a domain object may now 
expose a `BinaryObject` through the `ResultSet`. This is a 
backward-incompatible behavioral change and will break existing code; my 
project is one concrete example.
   The original issue concerns passing a composite primary-key object as a 
query parameter. It does not concern entities returned by table functions. 
Please keep the fix limited to parameter handling and revert this conversion.
   Moreover, a change affecting externally observable behavior and backward 
compatibility should not be introduced incidentally as part of this ticket. It 
requires a separate issue and a public discussion with the community, along 
with a compatibility assessment and tests proving that public query results 
remain unchanged.



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