ColinLeeo commented on code in PR #18982:
URL: https://github.com/apache/iotdb/pull/18982#discussion_r4346908010


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java:
##########
@@ -1599,13 +1604,11 @@ private Expression analyzeWhereSplitByDevice(
       final PartialPath devicePath,
       final ISchemaTree schemaTree,
       final MPPQueryContext queryContext) {
+    Expression wherePredicate =
+        
PredicateUtils.predicateRemoveNot(queryStatement.getWhereCondition().getPredicate());

Review Comment:
   Good catch on the partition-pruning half — that part is now fixed, not just 
described.
   
   `PredicateUtils#extractGlobalTimePredicate` now applies De Morgan when it 
meets a `NOT`: `NOT (A OR B)` is `NOT (A) AND NOT (B)`, so every disjunct that 
is a pure time predicate still bounds the time range of the negated predicate. 
`WHERE NOT (time > 2 OR s1 > 5)` therefore extracts `NOT (time > 2)`, which 
`predicateRemoveNot` turns into `time <= 2`, so partition fetching is limited 
to the partitions overlapping that range. Nested disjunctions are handled 
recursively.
   
   Deliberately not extracted: `NOT (A AND B)` (`NOT A OR NOT B` is a 
disjunction, so it cannot bound time) and `NOT NOT (A OR B)` (a disjunction 
again).
   
   On hoisting the rewrite out of the device loop: I kept it per device, 
because the rewrite is type-aware and needs each device's bound predicate — a 
series missing on one device becomes `NullOperand`, and the comparison operand 
types come from binding. The residual predicate and `hasValueFilter` are 
unchanged in the new extraction branch, so the `mutationJournal` handling and 
the later type-aware rewrite are untouched.
   
   Covered by `PredicateUtilsTest#testMixedNotOrExtractsNegatedTimePredicate`, 
`#testNestedMixedNotOrExtractsAllNegatedTimePredicates`, 
`#testNegatedOrWithoutPureTimeDisjunctDoesNotExtractTimePredicate` and 
`#testDoubleNegatedOrDoesNotExtractTimePredicate` (34c39add).
   



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