ColinLeeo commented on code in PR #18982:
URL: https://github.com/apache/iotdb/pull/18982#discussion_r4346921842
##########
integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBPredicateConversionTreeIT.java:
##########
@@ -290,4 +302,54 @@ public void testDoubleLiteralOverflow() {
expectedHeaderInt64,
allInt64Rows);
}
+
+ @Test
+ public void testWhereAndHavingWithNot() {
+ String[] expectedWhereHeader = new String[] {TIMESTAMP_STR, DEVICE_ID +
".int32_col"};
+ resultSetEqualTest(
+ "SELECT int32_col FROM " + DEVICE_ID + " WHERE NOT (int32_col > 20)",
+ expectedWhereHeader,
+ new String[] {"1,20,", "9,-29,", "10,-30,"});
+ resultSetEqualTest(
+ "SELECT int32_col FROM " + DEVICE_ID + " WHERE NOT (int32_col > 20 AND
int32_col < 40)",
+ expectedWhereHeader,
+ new String[] {"1,20,", "8,1000,", "9,-29,", "10,-30,"});
+
+ String[] expectedHavingHeader = new String[] {TIMESTAMP_STR,
count(DEVICE_ID + ".int32_col")};
+ resultSetEqualTest(
+ "SELECT count(int32_col) FROM "
+ + DEVICE_ID
+ + " GROUP BY ([1,11),2ms) HAVING NOT (count(int32_col) > 1)",
Review Comment:
The missing `HAVING NOT last_value(bool_series)` coverage is added now —
that was the one item from your list I had missed. Added in 1b9ddcfa:
- `testHavingNotWithBooleanAggregation`: `HAVING NOT last_value(b)` with
`GROUP BY ([1,5),1ms)`, plus the same query with `ALIGN BY DEVICE`.
- `testTemplatedHavingNotWithBooleanAggregation`: the aligned-template path,
`SELECT count(s1) FROM root.test_not_template.* GROUP BY ([1,3),1ms) HAVING NOT
last_value(b) ALIGN BY DEVICE`.
The other cases you listed were already in the PR: composite HAVING with and
without `GROUP BY LEVEL`, `WHERE NOT bool_series`, `WHERE NOT bool_series OR s1
> 5`, `NOT (CASE WHEN ...) OR ...`, triple negation and the NaN cases.
Verified locally on the latest head: `PredicateUtilsTest` 13/13 and
`IoTDBPredicateConversionTreeIT` 11/11 (including the two new tests).
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java:
##########
@@ -1030,10 +1030,12 @@ private void analyzeHavingBase(
ISchemaTree schemaTree,
UnaryOperator<Expression> havingExpressionAnalyzer,
MPPQueryContext queryContext) {
+ Expression havingPredicate =
+
PredicateUtils.predicateRemoveNot(queryStatement.getHavingCondition().getPredicate());
Review Comment:
For the record, the `HAVING NOT last_value(b)` coverage I mentioned in my
previous reply was not actually in the PR at that point. It is there now: both
the raw and the `ALIGN BY DEVICE` variants landed in 1b9ddcfa, and the
aligned-template variant too.
--
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]