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/10/07 06:45:09 UTC
[iotdb] 01/01: example
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/SQLexample
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 97a2f640cbe8dd1947b707aa037cb901dd62d541
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Fri Oct 7 14:44:40 2022 +0800
example
---
.../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 9 ++++-
.../antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 | 4 ++
.../iotdb/db/mpp/plan/parser/ASTVisitor.java | 8 ++++
.../plan/statement/dl/CreateModelStatement.java | 44 ++++++++++++++++++++++
4 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index 87c880e7bd..d0de78e2be 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -32,7 +32,7 @@ singleStatement
;
statement
- : ddlStatement | dmlStatement | dclStatement | utilityStatement | syncStatement
+ : ddlStatement | dmlStatement | dclStatement | utilityStatement | syncStatement | dlStatement
;
ddlStatement
@@ -68,6 +68,10 @@ syncStatement
: createPipeSink | showPipeSinkType | showPipeSink | dropPipeSink
| createPipe | showPipe | stopPipe | startPipe | dropPipe;
+dlStatement
+ : createModel
+ ;
+
/**
* 2. Data Definition Language (DDL)
*/
@@ -771,6 +775,9 @@ syncAttributeClauses
: attributePair (COMMA attributePair)*
;
+createModel
+ : CREATE MODEL selectStatement
+ ;
/**
* 7. Common Clauses
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index dd305e008f..cd6cb452ce 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -211,6 +211,10 @@ FILL
: F I L L
;
+MODEL
+ : M O D E L
+ ;
+
FILE
: F I L E
;
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 988515f530..ba73b8c1c9 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
@@ -81,6 +81,7 @@ import org.apache.iotdb.db.mpp.plan.statement.crud.DeleteDataStatement;
import org.apache.iotdb.db.mpp.plan.statement.crud.InsertStatement;
import org.apache.iotdb.db.mpp.plan.statement.crud.LoadTsFileStatement;
import org.apache.iotdb.db.mpp.plan.statement.crud.QueryStatement;
+import org.apache.iotdb.db.mpp.plan.statement.dl.CreateModelStatement;
import org.apache.iotdb.db.mpp.plan.statement.literal.BooleanLiteral;
import org.apache.iotdb.db.mpp.plan.statement.literal.DoubleLiteral;
import org.apache.iotdb.db.mpp.plan.statement.literal.Literal;
@@ -2957,4 +2958,11 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
}
return dropPipeSinkStatement;
}
+
+ @Override
+ public Statement visitCreateModel(IoTDBSqlParser.CreateModelContext ctx) {
+ CreateModelStatement createModelStatement = new CreateModelStatement();
+ createModelStatement.setQueryStatement((QueryStatement) visitSelectStatement(ctx.selectStatement()));
+ return createModelStatement;
+ }
}
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/dl/CreateModelStatement.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/dl/CreateModelStatement.java
new file mode 100644
index 0000000000..9706f5e3e4
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/dl/CreateModelStatement.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.dl;
+
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.mpp.plan.statement.Statement;
+import org.apache.iotdb.db.mpp.plan.statement.crud.QueryStatement;
+
+import java.util.List;
+
+public class CreateModelStatement extends Statement {
+
+ private QueryStatement queryStatement;
+
+ @Override
+ public List<? extends PartialPath> getPaths() {
+ return null;
+ }
+
+ public QueryStatement getQueryStatement() {
+ return queryStatement;
+ }
+
+ public void setQueryStatement(QueryStatement queryStatement) {
+ this.queryStatement = queryStatement;
+ }
+}