github-actions[bot] commented on code in PR #65262:
URL: https://github.com/apache/doris/pull/65262#discussion_r3578688631


##########
fe/be-java-extensions/iceberg-metadata-scanner/src/main/java/org/apache/doris/iceberg/IcebergSysTableJniScanner.java:
##########
@@ -106,9 +103,10 @@ protected int getNext() throws IOException {
                     break;
                 }
                 StructLike row = reader.next();
-                for (int i = 0; i < fields.size(); i++) {
-                    SelectedField field = fields.get(i);
-                    Object value = row.get(field.sourceIndex, 
field.field.type().typeId().javaClass());
+                for (int i = 0; i < requiredFieldCount; i++) {
+                    // FE keeps the fields requested by BE at the start of the 
Iceberg projection.
+                    // FileScanTask.schema() is not the row schema for every 
DataTask implementation.
+                    Object value = row.get(i, Object.class);
                     ColumnValue columnValue = new 
IcebergSysTableColumnValue(value, timezone);

Review Comment:
   This empty-projection path still loses the row count for `COUNT(*)`. With 
`requiredFieldCount == 0`, the scanner consumes each `StructLike` and 
increments the local `rows` counter, but it never appends anything to the 
zero-column `VectorTable`, so `JniScanner.getNextBatchMeta()` either hits the 
`numRows == vectorTable.getNumRows()` assertion or writes a metadata row count 
of 0. A Java-only `appendVirtualData(rows)` fix is also not enough end-to-end: 
the legacy scanner ultimately returns based on `Block::rows()`, which is 0 for 
a block with no columns, and the v2 JNI path checks `output_block->rows() == 
original_rows` after filling zero columns. Please either keep a cheap required 
output field for system-table `COUNT(*)` (avoiding `readable_metrics`) or add 
explicit BE support for propagating virtual zero-column row counts, and make 
these COUNT regressions assert the expected count.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to