ColinLeeo commented on code in PR #18982:
URL: https://github.com/apache/iotdb/pull/18982#discussion_r4345433442
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java:
##########
@@ -1110,7 +1112,8 @@ private void analyzeHaving(
Map<IDeviceID, Set<Expression>> deviceToOutputExpressions =
analysis.getDeviceToOutputExpressions();
- Expression havingExpression =
queryStatement.getHavingCondition().getPredicate();
+ Expression havingExpression =
+
PredicateUtils.predicateRemoveNot(queryStatement.getHavingCondition().getPredicate());
Review Comment:
Removed this hunk. The ALIGN BY DEVICE HAVING path now relies on the binder
root-context fix, and `HAVING NOT last_value(bool)` is covered by tests.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/TemplatedAggregationAnalyze.java:
##########
@@ -293,7 +293,8 @@ private static boolean analyzeHaving(Analysis analysis,
QueryStatement queryStat
Set<String> measurementSet = new HashSet<>(analysis.getMeasurementList());
Set<Expression> aggregationExpressions =
analysis.getAggregationExpressions();
- Expression havingExpression =
queryStatement.getHavingCondition().getPredicate();
+ Expression havingExpression =
+
PredicateUtils.predicateRemoveNot(queryStatement.getHavingCondition().getPredicate());
Review Comment:
Removed this hunk. The aligned-template HAVING path is unchanged, and
unsupported boolean HAVING predicates no longer go through `predicateRemoveNot`.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java:
##########
@@ -1573,9 +1576,11 @@ private void analyzeWhere(
if (!queryStatement.hasWhere()) {
return;
}
+ Expression wherePredicate =
Review Comment:
Addressed. Ordered comparisons are only inverted when both operand types are
known and non-FLOAT/DOUBLE. NaN cases retain `NOT` and are evaluated by
`FilterOperator`; regression tests cover both `NOT (x > 5 OR y > 2)` and `NOT
(x + y > 5)` with NaN.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java:
##########
@@ -1573,9 +1576,11 @@ private void analyzeWhere(
if (!queryStatement.hasWhere()) {
return;
}
+ Expression wherePredicate =
+
PredicateUtils.predicateRemoveNot(queryStatement.getWhereCondition().getPredicate());
List<Expression> conJunctions =
ExpressionAnalyzer.bindSchemaForPredicate(
- queryStatement.getWhereCondition().getPredicate(),
+ wherePredicate,
Review Comment:
Addressed. Nested `NOT` is now recursively normalized, and the binding
root-context leak through unary expressions is fixed. The triple-negation query
is covered by an integration test.
##########
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:
Moved away from the six pre-binding call sites. Rewriting is now type-aware
and happens after binding, which is required to preserve NaN semantics; the
duplicate binder bug is fixed directly. This necessarily runs on each device's
bound predicate in the ALIGN BY DEVICE path.
--
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]