You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "ycycse (via GitHub)" <gi...@apache.org> on 2023/01/31 04:52:13 UTC

[GitHub] [iotdb] ycycse opened a new pull request, #8941: [IOTDB-5341] The front end of eventWindow in aggregation query

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

   Design document: https://apache-iotdb.feishu.cn/docx/ELUMdYck2ov6V8xDJeAc95Xbnpg


-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] The front end of eventWindow in aggregation query

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1094528483


##########
antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4:
##########
@@ -475,6 +475,11 @@ groupByAttributeClause
     : TIME? LR_BRACKET (timeRange COMMA)? interval=DURATION_LITERAL (COMMA step=DURATION_LITERAL)? RR_BRACKET
     | LEVEL operator_eq INTEGER_LITERAL (COMMA INTEGER_LITERAL)*
     | TAGS LR_BRACKET identifier (COMMA identifier)* RR_BRACKET
+    | VARIATION LR_BRACKET expression (COMMA delta=INTEGER_LITERAL|realLiteral)? (COMMA keyValuePair)* RR_BRACKET

Review Comment:
   done



##########
antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4:
##########
@@ -475,6 +475,11 @@ groupByAttributeClause
     : TIME? LR_BRACKET (timeRange COMMA)? interval=DURATION_LITERAL (COMMA step=DURATION_LITERAL)? RR_BRACKET
     | LEVEL operator_eq INTEGER_LITERAL (COMMA INTEGER_LITERAL)*
     | TAGS LR_BRACKET identifier (COMMA identifier)* RR_BRACKET
+    | VARIATION LR_BRACKET expression (COMMA delta=INTEGER_LITERAL|realLiteral)? (COMMA keyValuePair)* RR_BRACKET
+    ;
+
+keyValuePair

Review Comment:
   done



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] The front end of eventWindow in aggregation query

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1094581134


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -180,6 +184,12 @@ public class AnalyzeVisitor extends StatementVisitor<Analysis, MPPQueryContext>
 
   private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
 
+  private static final Expression deviceExpression =
+      new TimeSeriesOperand(new MeasurementPath(new PartialPath(DEVICE, false), TSDataType.TEXT));

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -180,6 +184,12 @@ public class AnalyzeVisitor extends StatementVisitor<Analysis, MPPQueryContext>
 
   private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
 
+  private static final Expression deviceExpression =
+      new TimeSeriesOperand(new MeasurementPath(new PartialPath(DEVICE, false), TSDataType.TEXT));
+
+  private static final Expression endTimeExpression =
+      new TimeSeriesOperand(new MeasurementPath(new PartialPath(ENDTIME, false), TSDataType.INT64));

Review Comment:
   done



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] The front end of eventWindow in aggregation query

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1094580630


##########
server/src/main/java/org/apache/iotdb/db/mpp/aggregation/Accumulator.java:
##########
@@ -27,11 +27,16 @@
 public interface Accumulator {
 
   /**
-   * Column should be like: | ControlColumn | Time | Value |
+   * Column should be like: | ControlColumn | Time | Value | IgnoringNull is required when

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/mpp/aggregation/Accumulator.java:
##########
@@ -27,11 +27,16 @@
 public interface Accumulator {
 
   /**
-   * Column should be like: | ControlColumn | Time | Value |
+   * Column should be like: | ControlColumn | Time | Value | IgnoringNull is required when
+   * considering the value with null-controlColumn

Review Comment:
   done



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] The front end of eventWindow in aggregation query

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1095254568


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByComponent.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.db.mpp.plan.expression.Expression;
+import org.apache.iotdb.db.mpp.plan.statement.StatementNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroupByComponent extends StatementNode {
+
+  private Expression ControlColumnExpression;

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByComponent.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.db.mpp.plan.expression.Expression;
+import org.apache.iotdb.db.mpp.plan.statement.StatementNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroupByComponent extends StatementNode {

Review Comment:
   done



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1097427346


##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/RowBasedTimeJoinOperator.java:
##########
@@ -210,6 +214,7 @@ public boolean hasNext() {
       return false;
     }
     if (retainedTsBlock != null) {
+      LOGGER.info("Invalid true");

Review Comment:
   removed



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1097493856


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByParameter.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+/** The parameter of `GROUP BY` clause. */
+public abstract class GroupByParameter {
+
+  protected WindowType windowType;
+
+  protected boolean ignoringNull;
+
+  public GroupByParameter(WindowType windowType, boolean ignoringNull) {
+    this.windowType = windowType;
+    this.ignoringNull = ignoringNull;
+  }
+
+  public WindowType getWindowType() {
+    return windowType;
+  }
+
+  public boolean isIgnoringNull() {
+    return ignoringNull;
+  }
+
+  protected abstract void serializeAttributes(ByteBuffer byteBuffer);
+
+  protected abstract void serializeAttributes(DataOutputStream stream) throws IOException;
+
+  public void serialize(ByteBuffer buffer) {
+    ReadWriteIOUtils.write(windowType.getType(), buffer);
+    ReadWriteIOUtils.write(ignoringNull, buffer);
+    serializeAttributes(buffer);
+  }
+
+  public void serialize(DataOutputStream stream) throws IOException {
+    ReadWriteIOUtils.write(windowType.getType(), stream);
+    ReadWriteIOUtils.write(ignoringNull, stream);
+    serializeAttributes(stream);
+  }
+
+  public boolean equals(Object obj) {

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByParameter.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+/** The parameter of `GROUP BY` clause. */
+public abstract class GroupByParameter {
+
+  protected WindowType windowType;
+
+  protected boolean ignoringNull;
+
+  public GroupByParameter(WindowType windowType, boolean ignoringNull) {
+    this.windowType = windowType;
+    this.ignoringNull = ignoringNull;
+  }
+
+  public WindowType getWindowType() {
+    return windowType;
+  }
+
+  public boolean isIgnoringNull() {
+    return ignoringNull;
+  }
+
+  protected abstract void serializeAttributes(ByteBuffer byteBuffer);
+
+  protected abstract void serializeAttributes(DataOutputStream stream) throws IOException;
+
+  public void serialize(ByteBuffer buffer) {
+    ReadWriteIOUtils.write(windowType.getType(), buffer);
+    ReadWriteIOUtils.write(ignoringNull, buffer);
+    serializeAttributes(buffer);
+  }
+
+  public void serialize(DataOutputStream stream) throws IOException {
+    ReadWriteIOUtils.write(windowType.getType(), stream);
+    ReadWriteIOUtils.write(ignoringNull, stream);
+    serializeAttributes(stream);
+  }
+
+  public boolean equals(Object obj) {
+    if (!(obj instanceof GroupByParameter)) {
+      return false;
+    }
+    GroupByParameter other = (GroupByParameter) obj;
+    return this.windowType == other.windowType && this.ignoringNull == other.ignoringNull;
+  }
+
+  public int hashCode() {

Review Comment:
   done



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] The front end of eventWindow in aggregation query

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1095254646


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByComponent.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.db.mpp.plan.expression.Expression;
+import org.apache.iotdb.db.mpp.plan.statement.StatementNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroupByComponent extends StatementNode {
+
+  private Expression ControlColumnExpression;
+  private double delta = 0;
+
+  Map<String, String> pair = null;

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByParameter.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+/** The parameter of `GROUP BY`. including: `GROUP BY VARIATION` */
+public class GroupByParameter {

Review Comment:
   done



-- 
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] liuminghui233 commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "liuminghui233 (via GitHub)" <gi...@apache.org>.
liuminghui233 commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1095299721


##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/RowBasedTimeJoinOperator.java:
##########
@@ -210,6 +214,7 @@ public boolean hasNext() {
       return false;
     }
     if (retainedTsBlock != null) {
+      LOGGER.info("Invalid true");

Review Comment:
   remove debug log



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByVariationComponent.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+
+public class GroupByVariationComponent extends GroupByComponent {
+  private double delta = 0;
+
+  public GroupByVariationComponent(WindowType windowType) {

Review Comment:
   `windowType` is redundant?



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByParameter.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+/** The parameter of `GROUP BY` clause. */
+public abstract class GroupByParameter {
+
+  protected WindowType windowType;
+
+  protected boolean ignoringNull;
+
+  public GroupByParameter(WindowType windowType, boolean ignoringNull) {
+    this.windowType = windowType;
+    this.ignoringNull = ignoringNull;
+  }
+
+  public WindowType getWindowType() {
+    return windowType;
+  }
+
+  public boolean isIgnoringNull() {
+    return ignoringNull;
+  }
+
+  protected abstract void serializeAttributes(ByteBuffer byteBuffer);
+
+  protected abstract void serializeAttributes(DataOutputStream stream) throws IOException;
+
+  public void serialize(ByteBuffer buffer) {
+    ReadWriteIOUtils.write(windowType.getType(), buffer);
+    ReadWriteIOUtils.write(ignoringNull, buffer);
+    serializeAttributes(buffer);
+  }
+
+  public void serialize(DataOutputStream stream) throws IOException {
+    ReadWriteIOUtils.write(windowType.getType(), stream);
+    ReadWriteIOUtils.write(ignoringNull, stream);
+    serializeAttributes(stream);
+  }
+
+  public boolean equals(Object obj) {

Review Comment:
   ```suggestion
     @Override
     public boolean equals(Object obj) {
   ```
   Also forgotten in GroupByTimeParameter



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByParameter.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+/** The parameter of `GROUP BY` clause. */
+public abstract class GroupByParameter {
+
+  protected WindowType windowType;
+
+  protected boolean ignoringNull;
+
+  public GroupByParameter(WindowType windowType, boolean ignoringNull) {
+    this.windowType = windowType;
+    this.ignoringNull = ignoringNull;
+  }
+
+  public WindowType getWindowType() {
+    return windowType;
+  }
+
+  public boolean isIgnoringNull() {
+    return ignoringNull;
+  }
+
+  protected abstract void serializeAttributes(ByteBuffer byteBuffer);
+
+  protected abstract void serializeAttributes(DataOutputStream stream) throws IOException;
+
+  public void serialize(ByteBuffer buffer) {
+    ReadWriteIOUtils.write(windowType.getType(), buffer);
+    ReadWriteIOUtils.write(ignoringNull, buffer);
+    serializeAttributes(buffer);
+  }
+
+  public void serialize(DataOutputStream stream) throws IOException {
+    ReadWriteIOUtils.write(windowType.getType(), stream);
+    ReadWriteIOUtils.write(ignoringNull, stream);
+    serializeAttributes(stream);
+  }
+
+  public boolean equals(Object obj) {
+    if (!(obj instanceof GroupByParameter)) {
+      return false;
+    }
+    GroupByParameter other = (GroupByParameter) obj;
+    return this.windowType == other.windowType && this.ignoringNull == other.ignoringNull;
+  }
+
+  public int hashCode() {

Review Comment:
   ```suggestion
     @Override
     public int hashCode() {
   ```
   Also forgotten in GroupByTimeParameter



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -1114,7 +1139,89 @@ private TSDataType analyzeExpression(Analysis analysis, Expression expression) {
     return analysis.getType(expression);
   }
 
-  private void analyzeGroupBy(Analysis analysis, QueryStatement queryStatement) {
+  private void analyzeDeviceToGroupBy(
+      Analysis analysis,
+      QueryStatement queryStatement,
+      ISchemaTree schemaTree,
+      Set<PartialPath> deviceSet) {
+    if (queryStatement.getGroupByComponent() == null) {
+      return;
+    }
+    GroupByComponent groupByComponent = queryStatement.getGroupByComponent();
+    WindowType windowType = groupByComponent.getWindowType();
+
+    Map<String, Expression> deviceToGroupByExpression = new LinkedHashMap<>();
+    if (windowType == WindowType.EVENT_WINDOW) {
+      Expression expression = groupByComponent.getControlColumnExpression();
+      for (PartialPath device : deviceSet) {
+        List<Expression> groupByExpressionsOfOneDevice =
+            ExpressionAnalyzer.concatDeviceAndRemoveWildcard(expression, device, schemaTree);
+
+        if (groupByExpressionsOfOneDevice.size() != 1) {
+          throw new SemanticException("Expression in group by should indicate one value");
+        }
+        Expression groupByExpressionOfOneDevice = groupByExpressionsOfOneDevice.get(0);
+
+        // Aggregation expression shouldn't exist in group by clause.
+        List<Expression> aggregationExpression =
+            ExpressionAnalyzer.searchAggregationExpressions(groupByExpressionOfOneDevice);
+        if (aggregationExpression != null && aggregationExpression.size() != 0) {
+          throw new SemanticException("Aggregation expression shouldn't exist in group by clause");
+        }
+        analyzeExpression(analysis, groupByExpressionOfOneDevice);

Review Comment:
   need check data type of groupByExpression



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByVariationParameter.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+public class GroupByVariationParameter extends GroupByParameter {
+
+  double delta;
+
+  public GroupByVariationParameter(WindowType windowType, boolean ignoringNull, double delta) {

Review Comment:
   `windowType` is redundant?



##########
integration-test/src/test/java/org/apache/iotdb/db/it/groupby/IoTDBGroupByVariationIT.java:
##########
@@ -0,0 +1,492 @@
+/*
+ * 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.it.groupby;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBGroupByVariationIT {
+
+  // original data and aggregation results can be directly viewed in online doc:
+  // https://docs.google.com/spreadsheets/d/11YSt061_JON8OyQ1EqntSwJKiyMrV3Pepz-GaCHQrA4
+  private static final String[] SQLs =
+      new String[] {
+        "CREATE DATABASE root.ln.wf01.wt01",
+        "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=DOUBLE, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt01.hardware WITH DATATYPE=INT32, ENCODING=PLAIN",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(1, 35.7, false, 11)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(2, 35.8,  true, 22)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(3, 35.4, false, 33 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(4, 36.4, false, 44)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(5, 36.8, false, 55)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(10, 36.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(20, 37.8,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(30, 37.5, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(40, 37.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(50, 37.9, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(100, 38.0, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(150, 38.8,  true, 220)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(200, 38.6, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(250, 38.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(300, 38.3, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(400, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(440, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(480, null, null, 0)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(500, 38.2, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(510, 37.5,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(520, 37.4, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(530, 36.8, false, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(540, 37.4, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(580, 37.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(590, 37.9,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(600, 36.9, true, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(610, 38.2, true, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(620, 39.2, true, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(1500, 9.8, false, 666)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(1550, 10.2, true, 888)",
+        "flush"
+      };
+
+  private static final String[] SQLs2 =
+      new String[] {
+        "CREATE DATABASE root.ln.wf01.wt02",
+        "CREATE TIMESERIES root.ln.wf01.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt02.temperature WITH DATATYPE=DOUBLE, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt02.hardware WITH DATATYPE=INT32, ENCODING=PLAIN",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(1, 35.7, false, 11)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(2, 35.8,  true, 22)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(3, 35.4, false, 33 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(4, 36.4, false, 44)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(5, 36.8, false, 55)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(10, 36.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(20, 37.8,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(30, 37.5, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(40, 37.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(50, 37.9, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(100, 38.0, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(150, 38.8,  true, 220)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(200, 38.6, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(250, 38.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(300, 38.3, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(400, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(440, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(480, null, null, 0)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(500, 38.2, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(510, 37.5,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(520, 37.4, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(530, 36.8, false, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(540, 37.4, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(580, 37.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(590, 37.9,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(600, 36.9, true, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(610, 38.2, true, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(620, 39.2, true, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(1500, 9.8, false, 666)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(1550, 10.2, true, 888)",
+        "flush"
+      };
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvFactory.getEnv().getConfig().getCommonConfig().setPartitionInterval(1000);

Review Comment:
   It's better to turn off compaction in query tests.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -1114,7 +1139,89 @@ private TSDataType analyzeExpression(Analysis analysis, Expression expression) {
     return analysis.getType(expression);
   }
 
-  private void analyzeGroupBy(Analysis analysis, QueryStatement queryStatement) {
+  private void analyzeDeviceToGroupBy(
+      Analysis analysis,
+      QueryStatement queryStatement,
+      ISchemaTree schemaTree,
+      Set<PartialPath> deviceSet) {
+    if (queryStatement.getGroupByComponent() == null) {
+      return;
+    }
+    GroupByComponent groupByComponent = queryStatement.getGroupByComponent();
+    WindowType windowType = groupByComponent.getWindowType();
+
+    Map<String, Expression> deviceToGroupByExpression = new LinkedHashMap<>();
+    if (windowType == WindowType.EVENT_WINDOW) {
+      Expression expression = groupByComponent.getControlColumnExpression();
+      for (PartialPath device : deviceSet) {
+        List<Expression> groupByExpressionsOfOneDevice =
+            ExpressionAnalyzer.concatDeviceAndRemoveWildcard(expression, device, schemaTree);
+
+        if (groupByExpressionsOfOneDevice.size() != 1) {
+          throw new SemanticException("Expression in group by should indicate one value");
+        }
+        Expression groupByExpressionOfOneDevice = groupByExpressionsOfOneDevice.get(0);
+
+        // Aggregation expression shouldn't exist in group by clause.
+        List<Expression> aggregationExpression =
+            ExpressionAnalyzer.searchAggregationExpressions(groupByExpressionOfOneDevice);
+        if (aggregationExpression != null && aggregationExpression.size() != 0) {
+          throw new SemanticException("Aggregation expression shouldn't exist in group by clause");
+        }
+        analyzeExpression(analysis, groupByExpressionOfOneDevice);
+        deviceToGroupByExpression.put(device.getFullPath(), groupByExpressionOfOneDevice);
+      }
+
+      GroupByParameter groupByParameter =
+          new GroupByVariationParameter(
+              windowType,
+              groupByComponent.isIgnoringNull(),
+              ((GroupByVariationComponent) groupByComponent).getDelta());
+      analysis.setGroupByParameter(groupByParameter);
+      analysis.setDeviceToGroupByExpression(deviceToGroupByExpression);
+    } else {
+      throw new SemanticException("Unsupported window type");
+    }
+  }
+
+  private void analyzeGroupBy(
+      Analysis analysis, QueryStatement queryStatement, ISchemaTree schemaTree) {
+
+    if (queryStatement.getGroupByComponent() == null) {
+      return;
+    }
+    GroupByComponent groupByComponent = queryStatement.getGroupByComponent();
+    WindowType windowType = groupByComponent.getWindowType();
+
+    if (windowType == WindowType.EVENT_WINDOW) {
+
+      Expression groupByExpression = groupByComponent.getControlColumnExpression();
+      // Expression in group by variation clause only indicates one column
+      List<Expression> expressions =
+          ExpressionAnalyzer.removeWildcardInExpression(groupByExpression, schemaTree);
+      if (expressions.size() != 1) {
+        throw new SemanticException("Expression in group by should indicate one value");
+      }
+      // Aggregation expression shouldn't exist in group by clause.
+      List<Expression> aggregationExpression =
+          ExpressionAnalyzer.searchAggregationExpressions(expressions.get(0));
+      if (aggregationExpression != null && aggregationExpression.size() != 0) {
+        throw new SemanticException("Aggregation expression shouldn't exist in group by clause");
+      }
+      analyzeExpression(analysis, expressions.get(0));

Review Comment:
   need check data type of groupByExpression



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1097493489


##########
integration-test/src/test/java/org/apache/iotdb/db/it/groupby/IoTDBGroupByVariationIT.java:
##########
@@ -0,0 +1,492 @@
+/*
+ * 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.it.groupby;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBGroupByVariationIT {
+
+  // original data and aggregation results can be directly viewed in online doc:
+  // https://docs.google.com/spreadsheets/d/11YSt061_JON8OyQ1EqntSwJKiyMrV3Pepz-GaCHQrA4
+  private static final String[] SQLs =
+      new String[] {
+        "CREATE DATABASE root.ln.wf01.wt01",
+        "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=DOUBLE, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt01.hardware WITH DATATYPE=INT32, ENCODING=PLAIN",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(1, 35.7, false, 11)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(2, 35.8,  true, 22)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(3, 35.4, false, 33 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(4, 36.4, false, 44)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(5, 36.8, false, 55)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(10, 36.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(20, 37.8,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(30, 37.5, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(40, 37.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(50, 37.9, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(100, 38.0, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(150, 38.8,  true, 220)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(200, 38.6, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(250, 38.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(300, 38.3, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(400, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(440, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(480, null, null, 0)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(500, 38.2, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(510, 37.5,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(520, 37.4, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(530, 36.8, false, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(540, 37.4, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(580, 37.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(590, 37.9,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(600, 36.9, true, 330 )",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(610, 38.2, true, 440)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(620, 39.2, true, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(1500, 9.8, false, 666)",
+        "INSERT INTO root.ln.wf01.wt01(timestamp, temperature, status, hardware) values(1550, 10.2, true, 888)",
+        "flush"
+      };
+
+  private static final String[] SQLs2 =
+      new String[] {
+        "CREATE DATABASE root.ln.wf01.wt02",
+        "CREATE TIMESERIES root.ln.wf01.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt02.temperature WITH DATATYPE=DOUBLE, ENCODING=PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt02.hardware WITH DATATYPE=INT32, ENCODING=PLAIN",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(1, 35.7, false, 11)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(2, 35.8,  true, 22)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(3, 35.4, false, 33 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(4, 36.4, false, 44)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(5, 36.8, false, 55)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(10, 36.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(20, 37.8,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(30, 37.5, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(40, 37.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(50, 37.9, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(100, 38.0, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(150, 38.8,  true, 220)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(200, 38.6, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(250, 38.4, false, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(300, 38.3, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(400, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(440, null, null, 0)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(480, null, null, 0)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(500, 38.2, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(510, 37.5,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(520, 37.4, false, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(530, 36.8, false, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(540, 37.4, false, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(580, 37.8, false, 110)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(590, 37.9,  true, 220)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(600, 36.9, true, 330 )",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(610, 38.2, true, 440)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(620, 39.2, true, 550)",
+        "flush",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(1500, 9.8, false, 666)",
+        "INSERT INTO root.ln.wf01.wt02(timestamp, temperature, status, hardware) values(1550, 10.2, true, 888)",
+        "flush"
+      };
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvFactory.getEnv().getConfig().getCommonConfig().setPartitionInterval(1000);

Review Comment:
   done



-- 
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] liuminghui233 commented on a diff in pull request #8941: [IOTDB-5341] The front end of eventWindow in aggregation query

Posted by "liuminghui233 (via GitHub)" <gi...@apache.org>.
liuminghui233 commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1092677655


##########
server/src/main/java/org/apache/iotdb/db/mpp/aggregation/Accumulator.java:
##########
@@ -27,11 +27,16 @@
 public interface Accumulator {
 
   /**
-   * Column should be like: | ControlColumn | Time | Value |
+   * Column should be like: | ControlColumn | Time | Value | IgnoringNull is required when

Review Comment:
   comments are confusing, `IgnoringNull ....` need move to a new line



##########
antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4:
##########
@@ -475,6 +475,11 @@ groupByAttributeClause
     : TIME? LR_BRACKET (timeRange COMMA)? interval=DURATION_LITERAL (COMMA step=DURATION_LITERAL)? RR_BRACKET
     | LEVEL operator_eq INTEGER_LITERAL (COMMA INTEGER_LITERAL)*
     | TAGS LR_BRACKET identifier (COMMA identifier)* RR_BRACKET
+    | VARIATION LR_BRACKET expression (COMMA delta=INTEGER_LITERAL|realLiteral)? (COMMA keyValuePair)* RR_BRACKET
+    ;
+
+keyValuePair

Review Comment:
   should use `attributePair`



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -180,6 +184,12 @@ public class AnalyzeVisitor extends StatementVisitor<Analysis, MPPQueryContext>
 
   private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
 
+  private static final Expression deviceExpression =
+      new TimeSeriesOperand(new MeasurementPath(new PartialPath(DEVICE, false), TSDataType.TEXT));

Review Comment:
   ```suggestion
         TimeSeriesOperand.constructColumnHeaderExpression(DEVICE, TSDataType.TEXT);
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByComponent.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.db.mpp.plan.expression.Expression;
+import org.apache.iotdb.db.mpp.plan.statement.StatementNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroupByComponent extends StatementNode {
+
+  private Expression ControlColumnExpression;

Review Comment:
   ```suggestion
     protected Expression controlColumnExpression;
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByParameter.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+/** The parameter of `GROUP BY`. including: `GROUP BY VARIATION` */
+public class GroupByParameter {

Review Comment:
   Similar to `GroupByComponent`, the design needs to be rethought.



##########
antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4:
##########
@@ -475,6 +475,11 @@ groupByAttributeClause
     : TIME? LR_BRACKET (timeRange COMMA)? interval=DURATION_LITERAL (COMMA step=DURATION_LITERAL)? RR_BRACKET
     | LEVEL operator_eq INTEGER_LITERAL (COMMA INTEGER_LITERAL)*
     | TAGS LR_BRACKET identifier (COMMA identifier)* RR_BRACKET
+    | VARIATION LR_BRACKET expression (COMMA delta=INTEGER_LITERAL|realLiteral)? (COMMA keyValuePair)* RR_BRACKET

Review Comment:
   ```suggestion
       | VARIATION LR_BRACKET expression (COMMA delta=INTEGER_LITERAL|realLiteral)? (COMMA attributePair)? RR_BRACKET
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByComponent.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.db.mpp.plan.expression.Expression;
+import org.apache.iotdb.db.mpp.plan.statement.StatementNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroupByComponent extends StatementNode {

Review Comment:
   `GroupByComponent` may be an abstract class that contains an expression as a member variable. `GroupByVariationComponent` and other classes extend this class, and each class records its own unique parameters.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -180,6 +184,12 @@ public class AnalyzeVisitor extends StatementVisitor<Analysis, MPPQueryContext>
 
   private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
 
+  private static final Expression deviceExpression =
+      new TimeSeriesOperand(new MeasurementPath(new PartialPath(DEVICE, false), TSDataType.TEXT));
+
+  private static final Expression endTimeExpression =
+      new TimeSeriesOperand(new MeasurementPath(new PartialPath(ENDTIME, false), TSDataType.INT64));

Review Comment:
   ```suggestion
         TimeSeriesOperand.constructColumnHeaderExpression(ENDTIME, TSDataType.INT64);
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/aggregation/Accumulator.java:
##########
@@ -27,11 +27,16 @@
 public interface Accumulator {
 
   /**
-   * Column should be like: | ControlColumn | Time | Value |
+   * Column should be like: | ControlColumn | Time | Value | IgnoringNull is required when
+   * considering the value with null-controlColumn

Review Comment:
   Need to explain what the `null-controlColumn` is?



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByComponent.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.db.mpp.plan.expression.Expression;
+import org.apache.iotdb.db.mpp.plan.statement.StatementNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroupByComponent extends StatementNode {
+
+  private Expression ControlColumnExpression;
+  private double delta = 0;
+
+  Map<String, String> pair = null;

Review Comment:
   ```suggestion
     private boolean ignoringNull;
   ```
   Since all parameters are known and finite, we do not need this method to record parameters.



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1097442592


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByVariationParameter.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+public class GroupByVariationParameter extends GroupByParameter {
+
+  double delta;
+
+  public GroupByVariationParameter(WindowType windowType, boolean ignoringNull, double delta) {

Review Comment:
   the parameter is received as GroupByParameter. So we need windowType to judge what kind of parameter it is.



-- 
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] liuminghui233 merged pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "liuminghui233 (via GitHub)" <gi...@apache.org>.
liuminghui233 merged PR #8941:
URL: https://github.com/apache/iotdb/pull/8941


-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1097460040


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByVariationComponent.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+
+public class GroupByVariationComponent extends GroupByComponent {
+  private double delta = 0;
+
+  public GroupByVariationComponent(WindowType windowType) {

Review Comment:
   the same.



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1097460040


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByVariationComponent.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+
+public class GroupByVariationComponent extends GroupByComponent {
+  private double delta = 0;
+
+  public GroupByVariationComponent(WindowType windowType) {

Review Comment:
   the same.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByVariationParameter.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+public class GroupByVariationParameter extends GroupByParameter {
+
+  double delta;
+
+  public GroupByVariationParameter(WindowType windowType, boolean ignoringNull, double delta) {

Review Comment:
   the parameter is received as GroupByParameter. So we need windowType to judge what kind of parameter it is.



-- 
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] ycycse commented on a diff in pull request #8941: [IOTDB-5341] Support GROUP BY VARIATION in aggregation query (front end part)

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #8941:
URL: https://github.com/apache/iotdb/pull/8941#discussion_r1097494271


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByVariationParameter.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.planner.plan.parameter;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+public class GroupByVariationParameter extends GroupByParameter {
+
+  double delta;
+
+  public GroupByVariationParameter(WindowType windowType, boolean ignoringNull, double delta) {

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/GroupByVariationComponent.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.statement.component;
+
+import org.apache.iotdb.db.mpp.execution.operator.window.WindowType;
+
+public class GroupByVariationComponent extends GroupByComponent {
+  private double delta = 0;
+
+  public GroupByVariationComponent(WindowType windowType) {

Review Comment:
   done



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