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


##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -670,6 +670,8 @@ public void checkBlockRulesByScan(Planner planner) throws 
AnalysisException {
                         scanNode.getSelectedPartitionNum(),
                         scanNode.getSelectedSplitNum(),
                         scanNode.getCardinality(),
+                        scanNode.isPartitionedTable(),

Review Comment:
   This widens `require_partition_filter` from the old Hive-only path to every 
`FileScanNode`, but the new generic `ScanNode.hasPartitionPredicate()` flag is 
only populated for Hive/Hudi. `IcebergScanNode`, `PaimonScanNode`, and 
`MaxComputeScanNode` still leave it at the default `false`, while 
`isPartitionedTable()` is `true` for partitioned tables. With a rule like 
`require_partition_filter=true`, queries such as `SELECT * FROM iceberg_pt 
WHERE ds = '2026-04-09'` will now be rejected as `missing partition filter`, 
which both breaks valid queries and contradicts the PR's documented scope 
(`Iceberg` / other unwired external tables should not be covered yet).



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PruneOlapScanPartition.java:
##########
@@ -114,36 +115,24 @@ private Pair<LogicalRelation, Optional<Expression>> 
prunePartition(LogicalOlapSc
                 ConnectContext.get().getStatementContext().getNextRelationId(),
                 ctx.root.getOutput()), Optional.empty());
         }
-        return Pair.of(scan.withSelectedPartitionIds(prunedPartitions), 
prunedPartitionsByFilters.second);
+        return Pair.of(scan.withSelectedPartitionIds(prunedPartitions,
+                prunedPartitionsByFilters.hasPartitionPredicate),
+                prunedPartitionsByFilters.prunedPartitionPredicate);
     }
 
-    private Pair<List<Long>, Optional<Expression>> 
prunePartitionByFilters(LogicalOlapScan scan,
+    private PartitionPruneResult<Long> prunePartitionByFilters(LogicalOlapScan 
scan,
                                                OlapTable table,
                                                LogicalFilter filter,
                                                MatchingContext ctx) {
         Set<String> partitionColumnNameSet = 
Utils.execWithReturnVal(table::getPartitionColumnNames);
         if (partitionColumnNameSet.isEmpty()) {

Review Comment:
   When the query is restricted only by `TABLET(...)`, this branch feeds 
`hasPartitionPredicate=false` into `prunePartitionByTabletIds()`, so the final 
scan still looks like it has `missing partition filter`. With 
`require_partition_filter=true`, `SELECT * FROM part_tbl TABLET(12345)` gets 
blocked even though the scan is already narrower than any partition predicate. 
This query shape needs to satisfy the rule, or be exempted before the generic 
block-rule check.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PruneOlapScanPartition.java:
##########
@@ -163,15 +152,37 @@ private Pair<List<Long>, Optional<Expression>> 
prunePartitionByFilters(LogicalOl
                     .collect(Collectors.toMap(Function.identity(), 
allPartitions::get));
         }
         if (filter != null) {
-            Pair<List<Long>, Optional<Expression>> prunedPartitions = 
PartitionPruner.prune(
+            return PartitionPruner.pruneWithResult(
                     partitionSlots, filter.getPredicate(), idToPartitions, 
ctx.cascadesContext,
                     PartitionTableType.OLAP, sortedPartitionRanges);
-            return prunedPartitions;
         } else if (!manuallySpecifiedPartitions.isEmpty()) {

Review Comment:
   This marks explicit `PARTITION(...)` selection as 
`hasPartitionPredicate=false`. That means `SELECT * FROM part_tbl 
PARTITION(p20260409)` is rejected as `missing partition filter` under 
`require_partition_filter=true`, even though the query already names the only 
partition(s) it is allowed to scan. The rule is supposed to prevent accidental 
full partition scans, so explicit partition selection should not be treated the 
same as an unrestricted scan.



##########
be/src/information_schema/schema_sql_block_rule_status_scanner.cpp:
##########
@@ -42,6 +42,7 @@ std::vector<SchemaScanner::ColumnDesc>
                 {"CARDINALITY", TYPE_BIGINT, sizeof(int64_t), true},
                 {"GLOBAL", TYPE_BOOLEAN, sizeof(bool), true},
                 {"ENABLE", TYPE_BOOLEAN, sizeof(bool), true},
+                {"REQUIRE_PARTITION_FILTER", TYPE_BOOLEAN, sizeof(bool), true},

Review Comment:
   Adding a new schema-table column here changes the FE<->BE row width from 12 
cells to 13, but `_get_sql_block_rule_status_block_from_fe()` still hard-fails 
on any size mismatch. During a rolling upgrade, an old FE will still return 12 
cells and a new FE will return 13 cells, so `SELECT * FROM 
information_schema.sql_block_rule_status` can fail with `col size not equal` as 
soon as FE/BE versions are mixed. We need a compatibility path here (for 
example, tolerate missing/extra trailing `REQUIRE_PARTITION_FILTER` and fill 
`false` for older peers) before extending this RPC schema.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/PartitionPruner.java:
##########
@@ -157,13 +182,14 @@ public static <K extends Comparable<K>> Pair<List<K>, 
Optional<Expression>> prun
         }
     }
 
-    private static <K extends Comparable<K>> Pair<List<K>, 
Optional<Expression>> pruneInternal(
+    private static <K extends Comparable<K>> PartitionPruneResult<K> 
pruneInternal(
             List<Slot> partitionSlots,
             Expression partitionPredicate,
             Map<K, PartitionItem> idToPartitions, CascadesContext 
cascadesContext,
             PartitionTableType partitionTableType, 
Optional<SortedPartitionRanges<K>> sortedPartitionRanges) {

Review Comment:
   This flag is recorded before we know whether the extracted partition 
expression is actually usable for pruning. Any evaluable predicate on the 
partition slot will count here, even if it prunes nothing. For example, on a 
normal range-partitioned table `WHERE p IS NOT NULL` leaves 
`hasPartitionPredicate=true`, so `require_partition_filter` is satisfied even 
though the scan still reads every partition. The old 
`OlapScanNode.hasPartitionPredicate()` helper only treated predicates that 
`createPartitionFilter()` / `createColumnRange()` could really use for pruning 
as valid, so this creates a Nereids-only bypass.



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