hello-stephen commented on code in PR #71239:
URL: https://github.com/apache/doris/pull/71239#discussion_r4755646048


##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergScanPlanProvider.java:
##########
@@ -500,21 +499,28 @@ public long streamingSplitEstimate(ConnectorSession 
session, ConnectorTableHandl
         if (iceHandle.isResolvedEmptySnapshot() && !iceHandle.isSystemTable()) 
{
             resolveTable(session, iceHandle);
         }
-        if (iceHandle.isResolvedEmptySnapshot() || iceHandle.isSystemTable()
+        if (iceHandle.isResolvedEmptySnapshot()
                 || !sessionBool(session, ENABLE_EXTERNAL_TABLE_BATCH_MODE, 
true)) {
             return -1;
         }
+        if (iceHandle.isSystemTable()) {
+            Table base = resolveSysBaseTable(session, iceHandle);
+            return !isPositionDeletesSysTable(iceHandle) && 
!IcebergLabelsSysTable.isLabels(iceHandle)
+                    && IcebergEncryptionRead.isEncrypted(base) ? 1 : -1;
+        }
         Table table = resolveTable(session, iceHandle);
         TableScan scan = buildScan(table, iceHandle, filter, session);
         Snapshot snapshot = scan.snapshot();
         if (snapshot == null) {
             return -1;
         }
-        // V3 always plans synchronously; probing encrypted deletes here would 
reject a valid physical COUNT.
-        if (getFormatVersion(table) >= 3) {
+        boolean encrypted = IcebergEncryptionRead.isEncrypted(table);
+        // Plain V3/V4 DML consumes the delete-rewrite stash at plan time. 
Admitted encrypted tables
+        // reject every native write, so their read-only scans can safely 
retain lazy backpressure.
+        if (getFormatVersion(table) >= 3 && !encrypted) {

Review Comment:
   [P2] Mark encrypted lazy scans before dispatching the first batch
   
   A declared-encrypted v3/v4 table can still contain plaintext files before a 
keyed data/delete file. Allowing that table to stream here means a bounded 
plaintext prefix can be dispatched while shared scan params remain 
`FORMAT_PARQUET`: `getScanNodeProperties()` always starts with that default, 
and `setScanParams()` upgrades it only when a keyed range is converted. With 
COUNT pushdown enabled, `FileScannerV2::_init_table_reader()` therefore 
initializes COUNT once; when the same scanner later consumes the keyed range, 
`IcebergTableReader::prepare_split()` rejects it with `File encryption 
[AGGREGATE_UNAVAILABLE]`. This is reachable with small split batches/queues and 
a single scanner; eager v3/v4 planning previously discovered the marker before 
dispatch. Mark known-encrypted scans as protected, or disable aggregate 
pushdown, before initial dispatch and add a mixed plaintext-first lazy COUNT 
regression.



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