You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/07/10 07:38:07 UTC

[iotdb] branch master updated: Change Expression priority in IoTDBSqlparser.g4

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new ab8743e8bd5 Change Expression priority in IoTDBSqlparser.g4
ab8743e8bd5 is described below

commit ab8743e8bd52d0c5c20535001c819c0744dbcda0
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Mon Jul 10 15:38:01 2023 +0800

    Change Expression priority in IoTDBSqlparser.g4
---
 .../apache/iotdb/db/it/query/IoTDBArithmeticIT.java    | 18 ++++++++++++++++++
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4       |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBArithmeticIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBArithmeticIT.java
index 8108e5684a0..6c54b7f1875 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBArithmeticIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBArithmeticIT.java
@@ -223,4 +223,22 @@ public class IoTDBArithmeticIT {
       assertTrue(throwable.getMessage().contains("Invalid input expression data type."));
     }
   }
+
+  @Test
+  public void testNot() {
+    try (Connection connection = EnvFactory.getEnv().getConnection();
+        Statement statement = connection.createStatement();
+        ResultSet resultSet = statement.executeQuery("select not(s5), !s5 from root.sg.d1"); ) {
+      String[] retArray = new String[] {"true", "true", "false", "false", "false"};
+      int cnt = 0;
+      while (resultSet.next()) {
+        assertEquals(retArray[cnt], resultSet.getString(2));
+        assertEquals(retArray[cnt], resultSet.getString(3));
+        cnt++;
+      }
+      assertEquals(retArray.length, cnt);
+    } catch (SQLException throwable) {
+      fail();
+    }
+  }
 }
diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index 1e04b4646a1..03bdf13ef99 100644
--- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -1137,9 +1137,9 @@ expression
     | time=(TIME | TIMESTAMP)
     | caseWhenThenExpression
     | fullPathInExpression
+    | (PLUS | MINUS | operator_not) expressionAfterUnaryOperator=expression
     | scalarFunctionExpression
     | functionName LR_BRACKET expression (COMMA expression)* RR_BRACKET
-    | (PLUS | MINUS | operator_not) expressionAfterUnaryOperator=expression
     | leftExpression=expression (STAR | DIV | MOD) rightExpression=expression
     | leftExpression=expression (PLUS | MINUS) rightExpression=expression
     | leftExpression=expression (OPERATOR_GT | OPERATOR_GTE | OPERATOR_LT | OPERATOR_LTE | OPERATOR_SEQ | OPERATOR_DEQ | OPERATOR_NEQ) rightExpression=expression