27
27
import org .apache .iotdb .db .exception .sql .SemanticException ;
28
28
import org .apache .iotdb .db .index .common .IndexType ;
29
29
import org .apache .iotdb .db .metadata .path .PartialPath ;
30
- import org .apache .iotdb .db .mpp .common .filter .*;
30
+ import org .apache .iotdb .db .mpp .common .filter .BasicFunctionFilter ;
31
+ import org .apache .iotdb .db .mpp .common .filter .InFilter ;
32
+ import org .apache .iotdb .db .mpp .common .filter .LikeFilter ;
33
+ import org .apache .iotdb .db .mpp .common .filter .QueryFilter ;
34
+ import org .apache .iotdb .db .mpp .common .filter .RegexpFilter ;
31
35
import org .apache .iotdb .db .mpp .sql .constant .FilterConstant ;
32
- import org .apache .iotdb .db .mpp .sql .statement .*;
33
- import org .apache .iotdb .db .mpp .sql .statement .component .*;
34
- import org .apache .iotdb .db .mpp .sql .statement .crud .*;
36
+ import org .apache .iotdb .db .mpp .sql .statement .Statement ;
37
+ import org .apache .iotdb .db .mpp .sql .statement .component .FillComponent ;
38
+ import org .apache .iotdb .db .mpp .sql .statement .component .FilterNullComponent ;
39
+ import org .apache .iotdb .db .mpp .sql .statement .component .FromComponent ;
40
+ import org .apache .iotdb .db .mpp .sql .statement .component .GroupByLevelComponent ;
41
+ import org .apache .iotdb .db .mpp .sql .statement .component .GroupByTimeComponent ;
42
+ import org .apache .iotdb .db .mpp .sql .statement .component .OrderBy ;
43
+ import org .apache .iotdb .db .mpp .sql .statement .component .ResultColumn ;
44
+ import org .apache .iotdb .db .mpp .sql .statement .component .ResultSetFormat ;
45
+ import org .apache .iotdb .db .mpp .sql .statement .component .SelectComponent ;
46
+ import org .apache .iotdb .db .mpp .sql .statement .component .WhereCondition ;
47
+ import org .apache .iotdb .db .mpp .sql .statement .crud .AggregationQueryStatement ;
48
+ import org .apache .iotdb .db .mpp .sql .statement .crud .FillQueryStatement ;
49
+ import org .apache .iotdb .db .mpp .sql .statement .crud .GroupByFillQueryStatement ;
50
+ import org .apache .iotdb .db .mpp .sql .statement .crud .GroupByQueryStatement ;
51
+ import org .apache .iotdb .db .mpp .sql .statement .crud .InsertStatement ;
52
+ import org .apache .iotdb .db .mpp .sql .statement .crud .LastQueryStatement ;
53
+ import org .apache .iotdb .db .mpp .sql .statement .crud .QueryStatement ;
54
+ import org .apache .iotdb .db .mpp .sql .statement .crud .UDAFQueryStatement ;
55
+ import org .apache .iotdb .db .mpp .sql .statement .crud .UDTFQueryStatement ;
56
+ import org .apache .iotdb .db .mpp .sql .statement .metadata .AlterTimeSeriesStatement ;
35
57
import org .apache .iotdb .db .mpp .sql .statement .metadata .CreateAlignedTimeSeriesStatement ;
36
58
import org .apache .iotdb .db .mpp .sql .statement .metadata .CreateTimeSeriesStatement ;
37
59
import org .apache .iotdb .db .mpp .sql .statement .metadata .ShowDevicesStatement ;
45
67
import org .apache .iotdb .db .query .executor .fill .PreviousFill ;
46
68
import org .apache .iotdb .db .query .executor .fill .ValueFill ;
47
69
import org .apache .iotdb .db .query .expression .Expression ;
48
- import org .apache .iotdb .db .query .expression .binary .*;
70
+ import org .apache .iotdb .db .query .expression .binary .AdditionExpression ;
71
+ import org .apache .iotdb .db .query .expression .binary .DivisionExpression ;
72
+ import org .apache .iotdb .db .query .expression .binary .ModuloExpression ;
73
+ import org .apache .iotdb .db .query .expression .binary .MultiplicationExpression ;
74
+ import org .apache .iotdb .db .query .expression .binary .SubtractionExpression ;
49
75
import org .apache .iotdb .db .query .expression .unary .ConstantOperand ;
50
76
import org .apache .iotdb .db .query .expression .unary .FunctionExpression ;
51
77
import org .apache .iotdb .db .query .expression .unary .NegationExpression ;
62
88
import java .util .*;
63
89
import java .util .regex .Pattern ;
64
90
65
- import static org .apache .iotdb .db .index .common .IndexConstant .*;
91
+ import static org .apache .iotdb .db .index .common .IndexConstant .PATTERN ;
92
+ import static org .apache .iotdb .db .index .common .IndexConstant .THRESHOLD ;
93
+ import static org .apache .iotdb .db .index .common .IndexConstant .TOP_K ;
66
94
import static org .apache .iotdb .db .qp .constant .SQLConstant .TIME_PATH ;
67
95
68
96
/** Parse AST to Statement. */
@@ -121,7 +149,7 @@ public Statement visitCreateNonAlignedTimeseries(
121
149
public Statement visitCreateAlignedTimeseries (IoTDBSqlParser .CreateAlignedTimeseriesContext ctx ) {
122
150
CreateAlignedTimeSeriesStatement createAlignedTimeSeriesStatement =
123
151
new CreateAlignedTimeSeriesStatement ();
124
- createAlignedTimeSeriesStatement .setDeviceId (parseFullPath (ctx .fullPath ()));
152
+ createAlignedTimeSeriesStatement .setDevicePath (parseFullPath (ctx .fullPath ()));
125
153
parseAlignedMeasurements (ctx .alignedMeasurements (), createAlignedTimeSeriesStatement );
126
154
return createAlignedTimeSeriesStatement ;
127
155
}
@@ -233,11 +261,9 @@ public void parseTagClause(IoTDBSqlParser.TagClauseContext ctx, Statement statem
233
261
((CreateTimeSeriesStatement ) statement ).setTags (tags );
234
262
} else if (statement instanceof CreateAlignedTimeSeriesStatement ) {
235
263
((CreateAlignedTimeSeriesStatement ) statement ).addTagsList (tags );
264
+ } else if (statement instanceof AlterTimeSeriesStatement ) {
265
+ ((AlterTimeSeriesStatement ) statement ).setTagsMap (tags );
236
266
}
237
- // TODO: remove comments
238
- // else if (statement instanceof AlterTimeSeriesStatement) {
239
- // ((AlterTimeSeriesStatement) statement).setTagsMap(tags);
240
- // }
241
267
}
242
268
243
269
public void parseAttributeClause (IoTDBSqlParser .AttributeClauseContext ctx , Statement statement ) {
@@ -246,11 +272,66 @@ public void parseAttributeClause(IoTDBSqlParser.AttributeClauseContext ctx, Stat
246
272
((CreateTimeSeriesStatement ) statement ).setAttributes (attributes );
247
273
} else if (statement instanceof CreateAlignedTimeSeriesStatement ) {
248
274
((CreateAlignedTimeSeriesStatement ) statement ).addAttributesList (attributes );
275
+ } else if (statement instanceof AlterTimeSeriesStatement ) {
276
+ ((AlterTimeSeriesStatement ) statement ).setAttributesMap (attributes );
277
+ }
278
+ }
279
+
280
+ @ Override
281
+ public Statement visitAlterTimeseries (IoTDBSqlParser .AlterTimeseriesContext ctx ) {
282
+ AlterTimeSeriesStatement alterTimeSeriesStatement = new AlterTimeSeriesStatement ();
283
+ alterTimeSeriesStatement .setPath (parseFullPath (ctx .fullPath ()));
284
+ parseAlterClause (ctx .alterClause (), alterTimeSeriesStatement );
285
+ return alterTimeSeriesStatement ;
286
+ }
287
+
288
+ private void parseAlterClause (
289
+ IoTDBSqlParser .AlterClauseContext ctx , AlterTimeSeriesStatement alterTimeSeriesStatement ) {
290
+ Map <String , String > alterMap = new HashMap <>();
291
+ // rename
292
+ if (ctx .RENAME () != null ) {
293
+ alterTimeSeriesStatement .setAlterType (AlterTimeSeriesStatement .AlterType .RENAME );
294
+ alterMap .put (
295
+ parseIdentifier ((ctx .beforeName .getText ())), parseIdentifier (ctx .currentName .getText ()));
296
+ } else if (ctx .SET () != null ) {
297
+ // set
298
+ alterTimeSeriesStatement .setAlterType (AlterTimeSeriesStatement .AlterType .SET );
299
+ setMap (ctx , alterMap );
300
+ } else if (ctx .DROP () != null ) {
301
+ // drop
302
+ alterTimeSeriesStatement .setAlterType (AlterTimeSeriesStatement .AlterType .DROP );
303
+ for (IoTDBSqlParser .IdentifierContext dropId : ctx .identifier ()) {
304
+ alterMap .put (parseIdentifier (dropId .getText ()), null );
305
+ }
306
+ } else if (ctx .TAGS () != null ) {
307
+ // add tag
308
+ alterTimeSeriesStatement .setAlterType ((AlterTimeSeriesStatement .AlterType .ADD_TAGS ));
309
+ setMap (ctx , alterMap );
310
+ } else if (ctx .ATTRIBUTES () != null ) {
311
+ // add attribute
312
+ alterTimeSeriesStatement .setAlterType (AlterTimeSeriesStatement .AlterType .ADD_ATTRIBUTES );
313
+ setMap (ctx , alterMap );
314
+ } else {
315
+ // upsert
316
+ alterTimeSeriesStatement .setAlterType (AlterTimeSeriesStatement .AlterType .UPSERT );
317
+ if (ctx .aliasClause () != null ) {
318
+ parseAliasClause (ctx .aliasClause (), alterTimeSeriesStatement );
319
+ }
320
+ if (ctx .tagClause () != null ) {
321
+ parseTagClause (ctx .tagClause (), alterTimeSeriesStatement );
322
+ }
323
+ if (ctx .attributeClause () != null ) {
324
+ parseAttributeClause (ctx .attributeClause (), alterTimeSeriesStatement );
325
+ }
326
+ }
327
+ alterTimeSeriesStatement .setAlterMap (alterMap );
328
+ }
329
+
330
+ public void parseAliasClause (
331
+ IoTDBSqlParser .AliasClauseContext ctx , AlterTimeSeriesStatement alterTimeSeriesStatement ) {
332
+ if (alterTimeSeriesStatement != null && ctx .identifier () != null ) {
333
+ alterTimeSeriesStatement .setAlias ((parseIdentifier (ctx .identifier ().getText ())));
249
334
}
250
- // TODO: remove comments
251
- // else if (operator instanceof AlterTimeSeriesOperator) {
252
- // ((AlterTimeSeriesOperator) operator).setAttributesMap(attributes);
253
- // }
254
335
}
255
336
256
337
// Show Timeseries ========================================================================
0 commit comments