This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 615b856 [IOTDB-445] Unify the keyword of "timestamp" and "time" (#762)
615b856 is described below
commit 615b8567f45af4303e3c2ccfa16e6e99e3907978
Author: Boris <[email protected]>
AuthorDate: Mon Feb 3 18:15:06 2020 +0800
[IOTDB-445] Unify the keyword of "timestamp" and "time" (#762)
* add time and timestamp keyword.
---
.../org/apache/iotdb/db/qp/strategy/SqlBase.g4 | 8 ++-
.../iotdb/db/qp/strategy/LogicalGenerator.java | 5 +-
.../org/apache/iotdb/db/qp/QueryProcessorTest.java | 4 ++
.../iotdb/db/qp/plan/LogicalPlanSmallTest.java | 12 ++++
.../apache/iotdb/db/qp/plan/PhysicalPlanTest.java | 74 +++++++++++-----------
5 files changed, 63 insertions(+), 40 deletions(-)
diff --git a/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
b/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
index 4e2e47f..24fa59a 100644
--- a/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
+++ b/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
@@ -136,7 +136,7 @@ andExpression
;
predicate
- : (suffixPath | prefixPath) comparisonOperator constant
+ : (TIME | TIMESTAMP | suffixPath | prefixPath) comparisonOperator constant
| OPERATOR_NOT? LR_BRACKET orExpression RR_BRACKET
;
@@ -231,7 +231,7 @@ comparisonOperator
;
insertColumnSpec
- : LR_BRACKET TIMESTAMP (COMMA nodeNameWithoutStar)* RR_BRACKET
+ : LR_BRACKET (TIMESTAMP|TIME) (COMMA nodeNameWithoutStar)* RR_BRACKET
;
insertValuesSpec
@@ -727,6 +727,10 @@ ALIGN
COMPRESSION
: C O M P R E S S I O N
;
+
+TIME
+ : T I M E
+ ;
//============================
// End of the keywords list
//============================
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
index 509912e..6c93df5 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
@@ -1167,13 +1167,16 @@ public class LogicalGenerator extends
SqlBaseBaseListener {
return parseOrExpression(ctx.orExpression());
} else {
Path path = null;
- BasicFunctionOperator basic = null;
+ BasicFunctionOperator basic;
if (ctx.prefixPath() != null) {
path = parsePrefixPath(ctx.prefixPath());
}
if (ctx.suffixPath() != null) {
path = parseSuffixPath(ctx.suffixPath());
}
+ if(ctx.TIME() != null || ctx.TIMESTAMP() != null) {
+ path = new Path(SQLConstant.RESERVED_TIME);
+ }
if (ctx.constant().dateExpression() != null) {
if (!path.equals(SQLConstant.RESERVED_TIME)) {
throw new SQLParserException(path.toString(), "Date can only be used
to time");
diff --git
a/server/src/test/java/org/apache/iotdb/db/qp/QueryProcessorTest.java
b/server/src/test/java/org/apache/iotdb/db/qp/QueryProcessorTest.java
index d4bb9d2..4d5d92e 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/QueryProcessorTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/QueryProcessorTest.java
@@ -137,6 +137,10 @@ public class QueryProcessorTest {
String fillStatement = "select sensor1 from root.vehicle.device1 where
time = 50 Fill(int32[linear, 5m, 5m], boolean[previous, 5m])";
PhysicalPlan plan10 = processor.parseSQLToPhysicalPlan(fillStatement);
assertEquals(OperatorType.FILL, plan10.getOperatorType());
+
+ String insertTimeStatement = "insert into root.vehicle.d0(time,s0)
values(10,100)";
+ PhysicalPlan plan11 =
processor.parseSQLToPhysicalPlan(insertTimeStatement);
+ assertEquals(OperatorType.INSERT, plan11.getOperatorType());
}
@Test(expected = ParseCancellationException.class)
diff --git
a/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
b/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
index c20d112..617b289 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
@@ -95,6 +95,18 @@ public class LogicalPlanSmallTest {
Assert.assertEquals(100, ((QueryOperator) operator).getSeriesOffset());
}
+ @Test
+ public void testSOffsetTimestamp() {
+ String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and timestamp
<= now() limit 50 slimit 10 soffset 100";
+ RootOperator operator = (RootOperator) parseDriver
+ .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+ Assert.assertEquals(QueryOperator.class, operator.getClass());
+ Assert.assertEquals(50, ((QueryOperator) operator).getRowLimit());
+ Assert.assertEquals(0, ((QueryOperator) operator).getRowOffset());
+ Assert.assertEquals(10, ((QueryOperator) operator).getSeriesLimit());
+ Assert.assertEquals(100, ((QueryOperator) operator).getSeriesOffset());
+ }
+
@Test(expected = SQLParserException.class)
public void testLimitOutOfRange() {
String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <=
now() limit 1111111111111111111111";
diff --git
a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
index 9f38f50..7eb34b5 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
@@ -66,7 +66,7 @@ public class PhysicalPlanTest {
private QueryProcessor processor = new QueryProcessor(new
MemIntQpExecutor());
@Before
- public void before() throws QueryProcessException, StartupException {
+ public void before() throws QueryProcessException {
Path path1 = new Path(
new StringContainer(new String[]{"root", "vehicle", "d1", "s1"},
TsFileConstant.PATH_SEPARATOR));
@@ -97,7 +97,7 @@ public class PhysicalPlanTest {
@Test
public void testMetadata()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String metadata = "create timeseries root.vehicle.d1.s2 with
datatype=INT32,encoding=RLE";
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
CreateTimeSeriesPlan plan = (CreateTimeSeriesPlan)
processor.parseSQLToPhysicalPlan(metadata);
@@ -107,7 +107,7 @@ public class PhysicalPlanTest {
@Test
public void testMetadata2()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String metadata = "create timeseries root.vehicle.d1.s2 with
datatype=int32,encoding=rle";
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
CreateTimeSeriesPlan plan = (CreateTimeSeriesPlan)
processor.parseSQLToPhysicalPlan(metadata);
@@ -117,7 +117,7 @@ public class PhysicalPlanTest {
@Test
public void testAuthor()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sql = "grant role xm privileges
'SET_STORAGE_GROUP','DELETE_TIMESERIES' on root.vehicle.d1.s1";
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
AuthorPlan plan = (AuthorPlan) processor.parseSQLToPhysicalPlan(sql);
@@ -129,7 +129,7 @@ public class PhysicalPlanTest {
@Test
public void testProperty()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sql = "add label label1021 to property propropro";
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
PropertyPlan plan = (PropertyPlan) processor.parseSQLToPhysicalPlan(sql);
@@ -143,7 +143,7 @@ public class PhysicalPlanTest {
@Test
public void testAggregation()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "select sum(d1.s1) " + "from root.vehicle "
+ "where time <= 51 or !(time != 100 and time < 460)";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
@@ -156,7 +156,7 @@ public class PhysicalPlanTest {
@Test
public void testGroupBy1()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr =
"select count(s1) " + "from root.vehicle.d1 " + "where s1 < 20 and
time <= now() "
+ "group by([8,737], 3ms)";
@@ -204,7 +204,7 @@ public class PhysicalPlanTest {
@Test
public void testFill1()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE time = 5000
Fill(int32[linear, 5m, 5m], boolean[previous, 5m])";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
if (!plan.isQuery()) {
@@ -258,7 +258,7 @@ public class PhysicalPlanTest {
@Test
public void testQuery1()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE time > 5000";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -268,7 +268,7 @@ public class PhysicalPlanTest {
@Test
public void testQuery2()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE time > 50 and time
<= 100";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -280,7 +280,7 @@ public class PhysicalPlanTest {
@Test
public void testQuery3()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE time > 50 and time
<= 100 or s1 < 10";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -310,7 +310,7 @@ public class PhysicalPlanTest {
@Test
public void testQuery5()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 20 or s1 < 10";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -322,7 +322,7 @@ public class PhysicalPlanTest {
@Test
public void testQuery6()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE time > 20 or time <
10";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -334,7 +334,7 @@ public class PhysicalPlanTest {
@Test
public void testQuery7()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE time > 2019-10-16
10:59:00+08:00 - 1d5h or time < 10";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -345,7 +345,7 @@ public class PhysicalPlanTest {
@Test
public void testLimitOffset()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1,root.vehicle.d2 WHERE time
< 10 "
+ "limit 100 offset 10 slimit 1 soffset 1";
QueryPlan plan = (QueryPlan) processor.parseSQLToPhysicalPlan(sqlStr);
@@ -357,7 +357,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat1()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 20.5e3";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -368,7 +368,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat2()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 20.5E-3";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -379,7 +379,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat3()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 2.5";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -390,7 +390,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat4()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 2.5";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -401,7 +401,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat5()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > -2.5";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -412,7 +412,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat6()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > -2.5E-1";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -423,7 +423,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat7()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 2.5E2";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -434,7 +434,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat8()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > .2e2";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -445,7 +445,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat9()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > .2";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -456,7 +456,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat10()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 2.";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -467,7 +467,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat11()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > 2.";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -478,7 +478,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat12()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > -2.";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -489,7 +489,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat13()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > -.2";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -500,7 +500,7 @@ public class PhysicalPlanTest {
@Test
public void testQueryFloat14()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE s1 > -.2e2";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
IExpression queryFilter = ((QueryPlan) plan).getExpression();
@@ -511,7 +511,7 @@ public class PhysicalPlanTest {
@Test
public void testGrantWatermarkEmbedding()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "GRANT WATERMARK_EMBEDDING to a,b";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
DataAuthPlan dataAuthPlan = (DataAuthPlan) plan;
@@ -521,7 +521,7 @@ public class PhysicalPlanTest {
@Test
public void testRevokeWatermarkEmbedding()
- throws QueryProcessException, MetadataException {
+ throws QueryProcessException {
String sqlStr = "REVOKE WATERMARK_EMBEDDING from a,b";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
DataAuthPlan dataAuthPlan = (DataAuthPlan) plan;
@@ -530,7 +530,7 @@ public class PhysicalPlanTest {
}
@Test
- public void testConfiguration() throws QueryProcessException,
MetadataException {
+ public void testConfiguration() throws QueryProcessException {
String metadata = "load configuration";
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
LoadConfigurationPlan plan = (LoadConfigurationPlan)
processor.parseSQLToPhysicalPlan(metadata);
@@ -538,7 +538,7 @@ public class PhysicalPlanTest {
}
@Test
- public void testShowDynamicParameter() throws QueryProcessException,
MetadataException {
+ public void testShowDynamicParameter() throws QueryProcessException {
String metadata = "show dynamic parameter";
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
ShowPlan plan = (ShowPlan) processor.parseSQLToPhysicalPlan(metadata);
@@ -546,7 +546,7 @@ public class PhysicalPlanTest {
}
@Test
- public void testShowFlushInfo() throws QueryProcessException,
MetadataException {
+ public void testShowFlushInfo() throws QueryProcessException {
String metadata = "show flush task info";
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
ShowPlan plan = (ShowPlan) processor.parseSQLToPhysicalPlan(metadata);
@@ -554,7 +554,7 @@ public class PhysicalPlanTest {
}
@Test
- public void testLoadFiles() throws QueryProcessException, MetadataException {
+ public void testLoadFiles() throws QueryProcessException {
String filePath = "data" + File.separator + "213213441243-1-2.tsfile";
String metadata = String.format("load %s", filePath);
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
@@ -586,7 +586,7 @@ public class PhysicalPlanTest {
}
@Test
- public void testRemoveFile() throws QueryProcessException, MetadataException
{
+ public void testRemoveFile() throws QueryProcessException {
String filePath = "data" + File.separator + "213213441243-1-2.tsfile";
String metadata = String.format("remove %s", filePath);
QueryProcessor processor = new QueryProcessor(new MemIntQpExecutor());
@@ -597,7 +597,7 @@ public class PhysicalPlanTest {
}
@Test
- public void testMoveFile() throws QueryProcessException, MetadataException {
+ public void testMoveFile() throws QueryProcessException {
String filePath = "data" + File.separator + "213213441243-1-2.tsfile";
String targetDir = "user" + File.separator + "backup";
String metadata = String.format("move %s %s", filePath, targetDir);