sundapeng opened a new pull request, #9434:
URL: https://github.com/apache/paimon/pull/9434

   ### Purpose
   
   `PartitionPredicate.ALWAYS_FALSE` says "no partition can match", but 
`FormatTableScan` still handed it to the split enumerator, which then listed 
the table's partition directories and filtered every entry out. On a 
catalog-managed format table that listing is a remote FS call per partition 
level, so a query whose filter is provably unsatisfiable still paid the full 
listing cost before returning nothing.
   
   Two places now short-circuit on `ALWAYS_FALSE`:
   
   - `listPartitionEntries()` returns an empty list;
   - the scan-plan path returns `new ScanPlan(emptyList(), 
OptionalLong.of(0L))`, i.e. no splits and a row count of exactly 0 rather than 
"unknown".
   
   Both checks are reference comparisons against the singleton, which is why 
the anonymous `ALWAYS_FALSE` instance also gains `readResolve()`. 
`PartitionPredicate` is `Serializable` and is shipped to Flink/Spark tasks; 
without `readResolve` the deserialized copy is a distinct object and the 
reference check on the task side would silently miss, leaving the short-circuit 
working only on the client. `readResolve` makes the singleton survive a round 
trip so the optimization holds wherever the predicate lands.
   
   ### Tests
   
   `FormatTableAlwaysFalseScanTest` (new, 3 cases): `listPartitionEntries` 
returns empty without touching the enumerator, the scan plan reports zero 
splits and `rowCount == 0`, and `ALWAYS_FALSE` deserializes back to the same 
instance so the reference check still fires.
   
   ```
   mvn -pl paimon-core -am -DfailIfNoTests=false -DwildcardSuites=none \
     -Dtest=FormatTableAlwaysFalseScanTest,PartitionPredicateTest test
   ```
   
   Tests run: 11, Failures: 0, Errors: 0, Skipped: 0 (3 new + the existing 8 in 
`PartitionPredicateTest`). `spotless:check` + `checkstyle:check` pass.
   


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