github-actions[bot] commented on code in PR #67161:
URL: https://github.com/apache/doris/pull/67161#discussion_r3860846539
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PruneOlapScanPartition.java:
##########
@@ -132,14 +132,20 @@ private Pair<LogicalRelation, Optional<Expression>>
prunePartition(LogicalOlapSc
if (prunedPartitions == null) {
return Pair.of(null, Optional.empty());
}
+ boolean hasPartitionPredicate =
prunedPartitionsByFilters.hasPartitionPredicate
+ || !scan.getManuallySpecifiedPartitions().isEmpty()
+ || !scan.getManuallySpecifiedTabletIds().isEmpty();
if (prunedPartitions.isEmpty()) {
+ // Keep scan for short-circuit point queries even when no
partition matches.
+ // ShortCircuitQueryContext needs the scan to initialize and cache
the point-query path.
+ if (filter != null && ctx.statementContext.isShortCircuitQuery()) {
+ return Pair.of(scan.withSelectedPartitionIds(prunedPartitions,
hasPartitionPredicate),
Review Comment:
**[P1] Invalidate the cached partition map when topology changes**
This newly makes an initially unmatched prepared query cacheable, but the
cached `OlapScanNode` owns `PartitionPruneV2ForShortCircuitPlan`, whose range
map rebuild is throttled for 10 seconds. A concrete sequence is:
1. Execute `SELECT ... WHERE k=?` with a key outside all current range
partitions; this branch retains the scan and the first lazy execution builds
the old range map.
2. Add the matching partition and commit a row for that key.
3. Re-execute the prepared statement within 10 seconds.
`ShortCircuitQueryContext.isReusable()` still accepts the scan because
partition DDL does not change the base schema version. `update()` then skips
rebuilding and the lookup returns an empty batch for the committed row. Please
invalidate/rebuild on a partition metadata epoch/fingerprint rather than
elapsed time alone, and add an immediate post-`ADD PARTITION` prepared
regression.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PruneOlapScanPartition.java:
##########
@@ -132,14 +132,20 @@ private Pair<LogicalRelation, Optional<Expression>>
prunePartition(LogicalOlapSc
if (prunedPartitions == null) {
return Pair.of(null, Optional.empty());
}
+ boolean hasPartitionPredicate =
prunedPartitionsByFilters.hasPartitionPredicate
+ || !scan.getManuallySpecifiedPartitions().isEmpty()
+ || !scan.getManuallySpecifiedTabletIds().isEmpty();
if (prunedPartitions.isEmpty()) {
+ // Keep scan for short-circuit point queries even when no
partition matches.
+ // ShortCircuitQueryContext needs the scan to initialize and cache
the point-query path.
+ if (filter != null && ctx.statementContext.isShortCircuitQuery()) {
Review Comment:
**[P1] Preserve explicit partition/tablet restrictions before retaining this
scan**
This condition also fires when pruning became empty because of
`PARTITION(...)` or `TABLET(...)`. For example:
```text
ResultSink
Filter(order_id=2, pay_date='2026-08-06')
OlapScan(t PARTITION(p05))
```
If the matching row exists only in `p06`, pruning against the manual `p05`
set correctly produces `[]`, but this branch keeps the scan. Physical
translation does not carry `manuallySpecifiedPartitions`, and
`OlapScanNode.lazyEvaluateRangeLocations()` then reprunes from the whole table
and selects `p06`; the point-tablet path similarly ignores
`nereidsPrunedTabletIds`. Direct and prepared executions can therefore return a
row explicitly excluded by the SQL. Please either keep the empty relation when
a manual restriction is present, or propagate and intersect those allowed
partition/tablet sets in lazy pruning, with direct/prepared regressions.
--
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]