You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hu...@apache.org on 2022/09/08 13:44:30 UTC
[iotdb] 01/03: add IntoComponent
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/selectInto
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit a3749028b6fd1a54e8ee14600596dd84eea31db4
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Tue Aug 30 10:35:22 2022 +0800
add IntoComponent
---
.../iotdb/db/mpp/plan/parser/ASTVisitor.java | 17 ++++++++-
.../plan/statement/component/IntoComponent.java | 44 ++++++++++++++++++++++
.../db/mpp/plan/statement/crud/QueryStatement.java | 12 ++++++
3 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index 0c51b1a958..af8243890d 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -67,6 +67,7 @@ import org.apache.iotdb.db.mpp.plan.statement.component.FromComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.GroupByLevelComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.GroupByTimeComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.HavingCondition;
+import org.apache.iotdb.db.mpp.plan.statement.component.IntoComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.OrderByComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.Ordering;
import org.apache.iotdb.db.mpp.plan.statement.component.ResultColumn;
@@ -749,10 +750,15 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
// initialize query statement
queryStatement = new QueryStatement();
- // parser select, from
+ // parse select, from
parseSelectClause(ctx.selectClause());
parseFromClause(ctx.fromClause());
+ // parse into clause
+ if (ctx.intoClause() != null) {
+ parseIntoClause(ctx.intoClause());
+ }
+
// parse where clause
if (ctx.whereClause() != null) {
WhereCondition whereCondition = parseWhereClause(ctx.whereClause());
@@ -1303,6 +1309,15 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
}
}
+ // parse INTO clause
+
+ private void parseIntoClause(IoTDBSqlParser.IntoClauseContext ctx) {
+ boolean isAligned = ctx.ALIGNED() != null;
+ List<PartialPath> intoPaths = new ArrayList<>();
+
+ queryStatement.setIntoComponent(new IntoComponent(intoPaths, isAligned));
+ }
+
// Insert Statement ========================================================================
@Override
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/IntoComponent.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/IntoComponent.java
new file mode 100644
index 0000000000..02f471c396
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/component/IntoComponent.java
@@ -0,0 +1,44 @@
+/*
+ * 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.commons.path.PartialPath;
+
+import java.util.List;
+
+/** This class maintains information of {@code INTO} clause. */
+public class IntoComponent {
+
+ private final List<PartialPath> intoPaths;
+ private final boolean isAligned;
+
+ public IntoComponent(List<PartialPath> intoPaths, boolean isAligned) {
+ this.intoPaths = intoPaths;
+ this.isAligned = isAligned;
+ }
+
+ public List<PartialPath> getIntoPaths() {
+ return intoPaths;
+ }
+
+ public boolean isAligned() {
+ return isAligned;
+ }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java
index 0b06d17aa1..18b94088aa 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/QueryStatement.java
@@ -32,6 +32,7 @@ import org.apache.iotdb.db.mpp.plan.statement.component.FromComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.GroupByLevelComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.GroupByTimeComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.HavingCondition;
+import org.apache.iotdb.db.mpp.plan.statement.component.IntoComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.OrderByComponent;
import org.apache.iotdb.db.mpp.plan.statement.component.Ordering;
import org.apache.iotdb.db.mpp.plan.statement.component.ResultColumn;
@@ -91,6 +92,9 @@ public class QueryStatement extends Statement {
// `GROUP BY LEVEL` clause
protected GroupByLevelComponent groupByLevelComponent;
+ // `INTO` clause
+ protected IntoComponent intoComponent;
+
public QueryStatement() {
this.statementType = StatementType.QUERY;
}
@@ -244,6 +248,14 @@ public class QueryStatement extends Statement {
return orderByComponent != null && orderByComponent.isOrderByDevice();
}
+ public IntoComponent getIntoComponent() {
+ return intoComponent;
+ }
+
+ public void setIntoComponent(IntoComponent intoComponent) {
+ this.intoComponent = intoComponent;
+ }
+
public Ordering getResultTimeOrder() {
if (orderByComponent == null || !orderByComponent.isOrderByTime()) {
return Ordering.ASC;