Skip to content

Commit debf80d

Browse files
committed
Add EXPORT MODEL syntax
1 parent 51a91cc commit debf80d

File tree

6 files changed

+56
-1
lines changed

6 files changed

+56
-1
lines changed

traindb-core/src/main/antlr4/traindb/sql/TrainDBSql.g4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ traindbStmts
4141
| bypassDdlStmt
4242
| deleteQueryLogs
4343
| deleteTasks
44+
| exportModel
4445
;
4546

4647
createModeltype
@@ -114,6 +115,10 @@ optionValue
114115
| NUMERIC_LITERAL
115116
;
116117

118+
exportModel
119+
: K_EXPORT K_MODEL modelName
120+
;
121+
117122
showStmt
118123
: K_SHOW showTargets showWhereClause?
119124
;
@@ -219,6 +224,7 @@ K_DELETE : D E L E T E ;
219224
K_DESC : D E S C ;
220225
K_DESCRIBE : D E S C R I B E ;
221226
K_DROP : D R O P ;
227+
K_EXPORT : E X P O R T ;
222228
K_FOR : F O R ;
223229
K_FROM : F R O M ;
224230
K_HYPERPARAMETERS : H Y P E R P A R A M E T E R S ;

traindb-core/src/main/java/traindb/engine/TrainDBQueryEngine.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,11 @@ public void deleteTasks(Integer cnt) throws Exception {
681681
catalogContext.deleteTasks(cnt);
682682
}
683683

684+
@Override
685+
public TrainDBListResultSet exportModel(String modelName) throws Exception {
686+
throw new TrainDBException("Not supported yet");
687+
}
688+
684689
private void checkShowWhereColumns(Map<String, Object> patterns, List<String> columns)
685690
throws TrainDBException {
686691
for (String key : patterns.keySet()) {

traindb-core/src/main/java/traindb/sql/TrainDBSql.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ public static TrainDBListResultSet run(TrainDBSqlCommand command, TrainDBSqlRunn
135135
TrainDBSqlDeleteTasks deleteTasks = (TrainDBSqlDeleteTasks) command;
136136
runner.deleteTasks(deleteTasks.getRowCount());
137137
break;
138+
case EXPORT_MODEL:
139+
TrainDBSqlExportModel exportModel = (TrainDBSqlExportModel) command;
140+
return runner.exportModel(exportModel.getModelName());
138141
default:
139142
throw new RuntimeException("invalid TrainDB SQL command");
140143
}
@@ -292,6 +295,13 @@ public void exitDescribeTable(TrainDBSqlParser.DescribeTableContext ctx) {
292295
commands.add(new TrainDBSqlDescribeTable(schemaName, tableName));
293296
}
294297

298+
@Override
299+
public void exitExportModel(TrainDBSqlParser.ExportModelContext ctx) {
300+
String modelName = ctx.modelName().getText();
301+
LOG.debug("EXPORT MODEL: name=" + modelName);
302+
commands.add(new TrainDBSqlExportModel(modelName));
303+
}
304+
295305
@Override
296306
public void exitBypassDdlStmt(TrainDBSqlParser.BypassDdlStmtContext ctx) {
297307
int start = ctx.ddlString().getStart().getStartIndex();

traindb-core/src/main/java/traindb/sql/TrainDBSqlCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public enum Type {
3838
SHOW_TASKS,
3939
DELETE_QUERY_LOGS,
4040
DELETE_TASKS,
41+
EXPORT_MODEL,
4142
OTHER
4243
}
4344
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
package traindb.sql;
16+
17+
class TrainDBSqlExportModel extends TrainDBSqlCommand {
18+
private final String modelName;
19+
20+
TrainDBSqlExportModel(String modelName) {
21+
this.modelName = modelName;
22+
}
23+
24+
String getModelName() {
25+
return modelName;
26+
}
27+
28+
@Override
29+
public Type getType() {
30+
return Type.EXPORT_MODEL;
31+
}
32+
}

traindb-core/src/main/java/traindb/sql/TrainDBSqlRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ void trainModel(String modeltypeName, String modelName, String schemaName, Strin
6565
void deleteQueryLogs(Integer cnt) throws Exception;
6666

6767
void deleteTasks(Integer cnt) throws Exception;
68-
}
6968

69+
TrainDBListResultSet exportModel(String modelName) throws Exception;
70+
}

0 commit comments

Comments
 (0)