You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/21 12:52:51 UTC

[GitHub] [iotdb] Burgler01 opened a new pull request, #5980: [IOTDB-3173] Support Between expression in Transform Operator for StandAlone

Burgler01 opened a new pull request, #5980:
URL: https://github.com/apache/iotdb/pull/5980

   1.Modify the G4 file to support Between expression;
   2.Add abstract classes for ternary Expression and Transformer and implement their Between subclass;
   3.Modify the relevant code in the call link。


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] Burgler01 closed pull request #5980: [IOTDB-3173] Support Between expression in Transform Operator for StandAlone

Posted by GitBox <gi...@apache.org>.
Burgler01 closed pull request #5980: [IOTDB-3173] Support Between expression in Transform Operator for StandAlone
URL: https://github.com/apache/iotdb/pull/5980


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] Burgler01 closed pull request #5980: [IOTDB-3173] Support Between expression in Transform Operator

Posted by GitBox <gi...@apache.org>.
Burgler01 closed pull request #5980: [IOTDB-3173] Support Between expression in Transform Operator
URL: https://github.com/apache/iotdb/pull/5980


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] wangchao316 commented on a diff in pull request #5980: [IOTDB-3173] Support Between expression in Transform Operator

Posted by GitBox <gi...@apache.org>.
wangchao316 commented on code in PR #5980:
URL: https://github.com/apache/iotdb/pull/5980#discussion_r886364682


##########
integration/src/test/java/org/apache/iotdb/db/integration/IoTDBNestedQueryIT.java:
##########
@@ -586,6 +586,40 @@ public void testOrderOfArithmeticOperations() {
     }
   }
 
+  @Test
+  public void testBetweenExpression() {
+    try (Connection connection =
+            DriverManager.getConnection(
+                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+        Statement statement = connection.createStatement()) {
+      int start = 1, end = 5;
+      String query = "SELECT * FROM root.vehicle.d1 WHERE s1 BETWEEN " + start + " AND " + end;
+      try (ResultSet rs = statement.executeQuery(query)) {
+        for (int i = start; i <= end; i++) {
+          Assert.assertTrue(rs.next());
+          Assert.assertEquals(i, rs.getLong(1));
+          Assert.assertEquals(i, rs.getInt(2));
+        }
+      }
+
+      query =
+          "SELECT * FROM root.vehicle.d1 WHERE s1 NOT BETWEEN " // test not between
+              + (end + 1)
+              + " AND "
+              + ITERATION_TIMES;
+      try (ResultSet rs = statement.executeQuery(query)) {
+        for (int i = start; i <= end; i++) {
+          Assert.assertTrue(rs.next());
+          Assert.assertEquals(i, rs.getLong(1));
+          Assert.assertEquals(i, rs.getInt(2));
+        }
+      }
+    } catch (SQLException e) {
+      e.printStackTrace();

Review Comment:
   remove e.printStackTrace();



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java:
##########
@@ -104,7 +96,32 @@ public static void checkIsAllMeasurement(Expression expression) {
    * @return true if this expression is valid
    */
   public static ResultColumn.ColumnType identifyOutputColumnType(Expression expression) {
-    if (expression instanceof BinaryExpression) {
+    if (expression instanceof TernaryExpression) {
+      ResultColumn.ColumnType firstType =
+          identifyOutputColumnType(((TernaryExpression) expression).getFirstExpression());
+      ResultColumn.ColumnType secondType =
+          identifyOutputColumnType(((TernaryExpression) expression).getSecondExpression());
+      ResultColumn.ColumnType thirdType =
+          identifyOutputColumnType(((TernaryExpression) expression).getThirdExpression());
+      boolean rawFlag = false, aggregationFlag = false;

Review Comment:
   Line feed.  Only one variable can be defined in a row.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java:
##########
@@ -104,7 +96,32 @@ public static void checkIsAllMeasurement(Expression expression) {
    * @return true if this expression is valid
    */
   public static ResultColumn.ColumnType identifyOutputColumnType(Expression expression) {
-    if (expression instanceof BinaryExpression) {
+    if (expression instanceof TernaryExpression) {
+      ResultColumn.ColumnType firstType =
+          identifyOutputColumnType(((TernaryExpression) expression).getFirstExpression());
+      ResultColumn.ColumnType secondType =
+          identifyOutputColumnType(((TernaryExpression) expression).getSecondExpression());
+      ResultColumn.ColumnType thirdType =
+          identifyOutputColumnType(((TernaryExpression) expression).getThirdExpression());
+      boolean rawFlag = false, aggregationFlag = false;
+      if (firstType == ResultColumn.ColumnType.RAW
+          || secondType == ResultColumn.ColumnType.RAW
+          || thirdType == ResultColumn.ColumnType.RAW) rawFlag = true;

Review Comment:
   add {}



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionUtils.java:
##########
@@ -1,20 +1,5 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ *   * Licensed to the Apache Software Foundation (ASF) under one  * or more contributor license agreements.  See the NOTICE file  * distributed with this work for additional information  * regarding copyright ownership.  The ASF licenses this file  * to you under the Apache License, Version 2.0 (the  * "License"); you may not use this file except in compliance  * with the License.  You may obtain a copy of the License at  *  *     http://www.apache.org/licenses/LICENSE-2.0  *  * Unless required by applicable law or agreed to in writing,  * software distributed under the License is distributed on an  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY  * KIND, either express or implied.  See the License for the  * specific language governing permissions and limitations  * under the License.

Review Comment:
   ?



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/expression/ternary/BetweenExpression.java:
##########
@@ -0,0 +1,133 @@
+/*
+ *   * Licensed to the Apache Software Foundation (ASF) under one  * or more contributor license agreements.  See the NOTICE file  * distributed with this work for additional information  * regarding copyright ownership.  The ASF licenses this file  * to you under the Apache License, Version 2.0 (the  * "License"); you may not use this file except in compliance  * with the License.  You may obtain a copy of the License at  *  *     http://www.apache.org/licenses/LICENSE-2.0  *  * Unless required by applicable law or agreed to in writing,  * software distributed under the License is distributed on an  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY  * KIND, either express or implied.  See the License for the  * specific language governing permissions and limitations  * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.expression.ternary;
+
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.exception.query.LogicalOptimizeException;
+import org.apache.iotdb.db.mpp.plan.analyze.TypeProvider;
+import org.apache.iotdb.db.mpp.plan.expression.Expression;
+import org.apache.iotdb.db.mpp.plan.expression.ExpressionType;
+import org.apache.iotdb.db.mpp.transformation.api.LayerPointReader;
+import org.apache.iotdb.db.mpp.transformation.dag.transformer.ternary.BetweenTransformer;
+import org.apache.iotdb.db.mpp.transformation.dag.transformer.ternary.TernaryTransformer;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BetweenExpression extends TernaryExpression {
+  private final boolean isNotBetween;
+
+  public boolean isNotBetween() {
+    return isNotBetween;
+  }
+
+  public BetweenExpression(
+      Expression firstExpression,
+      Expression secondExpression,
+      Expression thirdExpression,
+      boolean isNotBetween) {
+    super(firstExpression, secondExpression, thirdExpression);
+    this.isNotBetween = isNotBetween;
+  }
+
+  public BetweenExpression(
+      Expression firstExpression, Expression secondExpression, Expression thirdExpression) {
+    super(firstExpression, secondExpression, thirdExpression);
+    this.isNotBetween = false;
+  }
+
+  public BetweenExpression(ByteBuffer byteBuffer) {
+    super(byteBuffer);
+    this.isNotBetween = ReadWriteIOUtils.readBool(byteBuffer);
+  }
+
+  @Override
+  public final void concat(List<PartialPath> prefixPaths, List<Expression> resultExpressions) {
+    List<Expression> firstExpressions = new ArrayList<>();
+    firstExpression.concat(prefixPaths, firstExpressions);
+
+    List<Expression> secondExpressions = new ArrayList<>();
+    secondExpression.concat(prefixPaths, secondExpressions);
+
+    List<Expression> thirdExpressions = new ArrayList<>();
+    secondExpression.concat(prefixPaths, thirdExpressions);
+
+    reconstruct(firstExpressions, secondExpressions, thirdExpressions, resultExpressions);
+  }
+
+  @Override
+  public final void removeWildcards(
+      org.apache.iotdb.db.qp.utils.WildcardsRemover wildcardsRemover,
+      List<Expression> resultExpressions)
+      throws LogicalOptimizeException {
+    List<Expression> firstExpressions = new ArrayList<>();
+    firstExpression.removeWildcards(wildcardsRemover, firstExpressions);
+
+    List<Expression> secondExpressions = new ArrayList<>();
+    secondExpression.removeWildcards(wildcardsRemover, secondExpressions);
+
+    List<Expression> thirdExpressions = new ArrayList<>();
+    thirdExpression.removeWildcards(wildcardsRemover, secondExpressions);
+    reconstruct(firstExpressions, secondExpressions, thirdExpressions, resultExpressions);
+  }
+
+  private void reconstruct(
+      List<Expression> firstExpressions,
+      List<Expression> secondExpressions,
+      List<Expression> thirdExpressions,
+      List<Expression> resultExpressions) {
+    for (Expression fe : firstExpressions) {
+      for (Expression se : secondExpressions)
+        for (Expression te : thirdExpressions) {
+          switch (operator()) {
+            case "between":

Review Comment:
   add "between" to FilterConstant



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java:
##########
@@ -1,20 +1,5 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ *   * Licensed to the Apache Software Foundation (ASF) under one  * or more contributor license agreements.  See the NOTICE file  * distributed with this work for additional information  * regarding copyright ownership.  The ASF licenses this file  * to you under the Apache License, Version 2.0 (the  * "License"); you may not use this file except in compliance  * with the License.  You may obtain a copy of the License at  *  *     http://www.apache.org/licenses/LICENSE-2.0  *  * Unless required by applicable law or agreed to in writing,  * software distributed under the License is distributed on an  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY  * KIND, either express or implied.  See the License for the  * specific language governing permissions and limitations  * under the License.

Review Comment:
   the same questition, Line feed



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org