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


##########
integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBPredicateConversionTreeIT.java:
##########
@@ -57,7 +61,15 @@ public class IoTDBPredicateConversionTreeIT {
         "INSERT INTO " + DEVICE_ID + "(time, int32_col, int64_col) VALUES(7, 
null, null)",
         "INSERT INTO " + DEVICE_ID + "(time, int32_col, int64_col) VALUES(8, 
1000, 1000)",
         "INSERT INTO " + DEVICE_ID + "(time, int32_col, int64_col) VALUES(9, 
-29, -29)",
-        "INSERT INTO " + DEVICE_ID + "(time, int32_col, int64_col) VALUES(10, 
-30, -30)"
+        "INSERT INTO " + DEVICE_ID + "(time, int32_col, int64_col) VALUES(10, 
-30, -30)",
+        "CREATE DATABASE " + TEMPLATE_DATABASE_NAME,
+        "CREATE DEVICE TEMPLATE not_predicate_template (s1 INT64)",

Review Comment:
   Changed the template to `ALIGNED` and added a residual boolean `NOT` case on 
that aligned template.



##########
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:
   Added the requested coverage: composite HAVING with and without GROUP BY 
LEVEL, non-invertible boolean series/functions/CASE, triple negation, NaN, and 
aligned-template predicates.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/visitor/logical/PredicateCanPushDownToSourceChecker.java:
##########
@@ -37,4 +38,11 @@ public Boolean visitIsNullExpression(IsNullExpression 
isNullExpression, Void con
   public Boolean visitLeafOperand(LeafOperand leafOperand, Void context) {
     return Boolean.TRUE;
   }
+
+  @Override
+  public Boolean visitLogicNotExpression(LogicNotExpression 
logicNotExpression, Void context) {
+    // TsFile filters cannot represent NOT. Predicates that cannot be inverted 
during analysis must

Review Comment:
   Kept the checker conservative for any residual logical `NOT`: correctness is 
preferred because TsFile cannot represent it. Such predicates stay in 
`FilterOperator`; the comment now matches the actual behavior.



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