924060929 commented on code in PR #71242:
URL: https://github.com/apache/doris/pull/71242#discussion_r4763942894


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -3300,18 +3307,21 @@ private OlapTable getStorageSemanticTable(OlapScanNode 
scanNode) {
     }
 
     /**
-     * Get the smallest slot in the slot list.
+     * Get the smallest slot whose type has no unsupported fields.
      *
      * @param slots slot list
-     * @return the smallest slot
+     * @return the smallest eligible slot, or null if none is available
      */
     @VisibleForTesting
     @Nullable
     public static SlotDescriptor getSmallestSlot(List<SlotDescriptor> slots) {
         if (slots == null || slots.isEmpty()) {
             return null;
         }
-        return Collections.min(slots, new SlotSizeComparator());
+        return slots.stream()
+                .filter(slot -> !slot.getType().typeContainsUnsupported())
+                .min(new SlotSizeComparator())
+                .orElse(null);

Review Comment:
   Under the current architecture, `LogicalFileScan` / `PhysicalFileScan` do 
not prune their own outputs (`computeOutput()` always exposes the full table 
schema, including `UNSUPPORTED` columns), and `CheckDataTypes` only inspects 
`plan.getExpressions()`.
   
   For queries like `SELECT COUNT(*) FROM mixed_types`, `ColumnPruning` places 
an empty `LogicalProject([])` above the scan and defers fallback column 
selection to `PhysicalPlanTranslator.updateScanSlotsMaterialization()` -> 
`getSmallestSlot()`. Until scans prune their own outputs or `COUNT(*)` fallback 
selection is moved earlier in Nereids, the translator will inevitably see 
`UNSUPPORTED` columns from the scan tuple.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -3061,6 +3061,13 @@ private void updateScanSlotsMaterialization(ScanNode 
scanNode,
         SlotDescriptor smallest = 
getSmallestSlot(scanNode.getTupleDesc().getSlots());
         scanNode.getTupleDesc().getSlots().removeIf(s -> 
!requiredWithVirtualColumns.contains(s.getId()));
         if (scanNode.getTupleDesc().getSlots().isEmpty()) {
+            // COUNT(*) hides source types from expression checks, but BE 
still constructs this scan slot.
+            if (smallest == null) {

Review Comment:
   [P2] Consider also rejecting all-unsupported scans earlier in 
`CheckDataTypes` (when every column in a `LogicalCatalogRelation`'s output 
contains `UnsupportedType`, no valid scan is possible regardless of upper 
projections). Note that the `getSmallestSlot` filter here is still needed for 
mixed-schema tables.
   
   [P2] (Pre-existing, non-blocking for this PR) A parallel fallback-column 
selection path exists in `ColumnPruning.pruneOutput()` -> 
`ExpressionUtils.selectMinimumColumn()`. It skips scalar `UnsupportedType` only 
because `width() == -1`, whereas nested types like `ARRAY<UNSUPPORTED>` have 
positive `width()` and can still be selected for a mixed-schema subquery 
`COUNT(*)`, causing `CheckDataTypes` to reject a valid query. Worth tracking 
separately.



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