This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new aec89d3569 [IOTDB-3290] modify check logic of CreateTimeSeries (#6013)
aec89d3569 is described below
commit aec89d3569cd3d39b7f5e7e241a3c5d79a3c0b52
Author: Liao Lanyu <[email protected]>
AuthorDate: Wed May 25 23:01:41 2022 +0800
[IOTDB-3290] modify check logic of CreateTimeSeries (#6013)
---
.../apache/iotdb/db/mpp/plan/analyze/Analyzer.java | 59 --------------------
.../iotdb/db/mpp/plan/parser/ASTVisitor.java | 62 ++++++++++++++++++++++
.../qp/logical/sys/CreateTimeSeriesOperator.java | 58 --------------------
.../apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java | 61 +++++++++++++++++++++
.../iotdb/db/qp/strategy/LogicalChecker.java | 5 --
5 files changed, 123 insertions(+), 122 deletions(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
index d2f45dd400..f1176643a9 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
@@ -27,7 +27,6 @@ import
org.apache.iotdb.commons.partition.SchemaNodeManagementPartition;
import org.apache.iotdb.commons.partition.SchemaPartition;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.confignode.rpc.thrift.NodeManagementType;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
import org.apache.iotdb.db.mpp.common.MPPQueryContext;
@@ -73,10 +72,7 @@ import
org.apache.iotdb.db.mpp.plan.statement.metadata.ShowDevicesStatement;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.ShowStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowTTLStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowTimeSeriesStatement;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
import org.apache.iotdb.tsfile.read.filter.GroupByFilter;
import org.apache.iotdb.tsfile.read.filter.basic.Filter;
import org.apache.iotdb.tsfile.read.filter.factory.FilterFactory;
@@ -862,7 +858,6 @@ public class Analyzer {
public Analysis visitCreateTimeseries(
CreateTimeSeriesStatement createTimeSeriesStatement, MPPQueryContext
context) {
context.setQueryType(QueryType.WRITE);
- checkProps(createTimeSeriesStatement);
if (createTimeSeriesStatement.getTags() != null
&& !createTimeSeriesStatement.getTags().isEmpty()
&& createTimeSeriesStatement.getAttributes() != null
@@ -885,60 +880,6 @@ public class Analyzer {
return analysis;
}
- private void checkProps(CreateTimeSeriesStatement
createTimeSeriesStatement) {
- Map<String, String> props = createTimeSeriesStatement.getProps();
- if
(!props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase())) {
- throw new SemanticException("datatype must be declared");
- }
- String datatypeString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase()).toUpperCase();
- try {
-
createTimeSeriesStatement.setDataType(TSDataType.valueOf(datatypeString));
- props.remove(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(String.format("Unsupported datatype: %s",
datatypeString));
- }
-
- final IoTDBDescriptor ioTDBDescriptor = IoTDBDescriptor.getInstance();
- createTimeSeriesStatement.setEncoding(
-
ioTDBDescriptor.getDefaultEncodingByType(createTimeSeriesStatement.getDataType()));
- if
(props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase())) {
- String encodingString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase()).toUpperCase();
- try {
-
createTimeSeriesStatement.setEncoding(TSEncoding.valueOf(encodingString));
- props.remove(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(String.format("Unsupported encoding:
%s", encodingString));
- }
- }
-
- createTimeSeriesStatement.setCompressor(
- TSFileDescriptor.getInstance().getConfig().getCompressor());
- if
(props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase())) {
- String compressionString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase()).toUpperCase();
- try {
-
createTimeSeriesStatement.setCompressor(CompressionType.valueOf(compressionString));
-
props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(
- String.format("Unsupported compression: %s", compressionString));
- }
- } else if
(props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase())) {
- String compressorString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase()).toUpperCase();
- try {
-
createTimeSeriesStatement.setCompressor(CompressionType.valueOf(compressorString));
-
props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(
- String.format("Unsupported compression: %s", compressorString));
- }
- }
- createTimeSeriesStatement.setProps(props);
- }
-
@Override
public Analysis visitCreateAlignedTimeseries(
CreateAlignedTimeSeriesStatement createAlignedTimeSeriesStatement,
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 74b931ce34..8426e8bbfe 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
@@ -211,7 +211,9 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
parseAttributeValue(attributePair.attributeValue()).toLowerCase());
}
}
+
createTimeSeriesStatement.setProps(props);
+ checkPropsInCreateTimeSeries(createTimeSeriesStatement);
if (ctx.tagClause() != null) {
parseTagClause(ctx.tagClause(), createTimeSeriesStatement);
@@ -221,6 +223,66 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
}
}
+ /** check and set datatype, encoding, compressor */
+ private void checkPropsInCreateTimeSeries(CreateTimeSeriesStatement
createTimeSeriesStatement) {
+ Map<String, String> props = createTimeSeriesStatement.getProps();
+ if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase())) {
+ String datatypeString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesStatement.setDataType(TSDataType.valueOf(datatypeString));
+ props.remove(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(String.format("Unsupported datatype: %s",
datatypeString));
+ }
+ }
+ if (createTimeSeriesStatement.getDataType() == null) {
+ throw new SemanticException("datatype must be declared");
+ }
+
+ final IoTDBDescriptor ioTDBDescriptor = IoTDBDescriptor.getInstance();
+ createTimeSeriesStatement.setEncoding(
+
ioTDBDescriptor.getDefaultEncodingByType(createTimeSeriesStatement.getDataType()));
+ if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase())) {
+ String encodingString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesStatement.setEncoding(TSEncoding.valueOf(encodingString));
+ props.remove(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(String.format("Unsupported encoding: %s",
encodingString));
+ }
+ }
+
+ createTimeSeriesStatement.setCompressor(
+ TSFileDescriptor.getInstance().getConfig().getCompressor());
+ if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase())) {
+ String compressionString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesStatement.setCompressor(CompressionType.valueOf(compressionString));
+
props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(
+ String.format("Unsupported compression: %s", compressionString));
+ }
+ } else if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase())) {
+ String compressorString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesStatement.setCompressor(CompressionType.valueOf(compressorString));
+ props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(String.format("Unsupported compression:
%s", compressorString));
+ }
+ }
+ createTimeSeriesStatement.setProps(props);
+ }
+
public void parseAttributeClauses(
IoTDBSqlParser.AttributeClausesContext ctx,
CreateAlignedTimeSeriesStatement createAlignedTimeSeriesStatement) {
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/CreateTimeSeriesOperator.java
b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/CreateTimeSeriesOperator.java
index b359fb3187..a059ce3ccb 100644
---
a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/CreateTimeSeriesOperator.java
+++
b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/CreateTimeSeriesOperator.java
@@ -18,16 +18,12 @@
*/
package org.apache.iotdb.db.qp.logical.sys;
-import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.qp.logical.Operator;
import org.apache.iotdb.db.qp.physical.PhysicalPlan;
import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
@@ -128,58 +124,4 @@ public class CreateTimeSeriesOperator extends Operator {
return new CreateTimeSeriesPlan(
path, dataType, encoding, compressor, props, tags, attributes, alias);
}
-
- /**
- * check datatype,encoding,compressor
- *
- * @throws SemanticException e
- */
- public void check() throws SemanticException {
- if
(!props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase())) {
- throw new SemanticException("datatype must be declared");
- }
- String datatypeString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase()).toUpperCase();
- try {
- this.dataType = TSDataType.valueOf(datatypeString);
- props.remove(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(String.format("Unsupported datatype: %s",
datatypeString));
- }
-
- final IoTDBDescriptor ioTDBDescriptor = IoTDBDescriptor.getInstance();
- this.encoding = ioTDBDescriptor.getDefaultEncodingByType(this.dataType);
- if
(props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase())) {
- String encodingString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase()).toUpperCase();
- try {
- this.encoding = TSEncoding.valueOf(encodingString);
- props.remove(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(String.format("Unsupported encoding: %s",
encodingString));
- }
- }
-
- this.compressor =
TSFileDescriptor.getInstance().getConfig().getCompressor();
- if (props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION)) {
- String compressionString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase()).toUpperCase();
- try {
- this.compressor = CompressionType.valueOf(compressionString);
-
props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(
- String.format("Unsupported compression: %s", compressionString));
- }
- } else if (props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR)) {
- String compressorString =
-
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase()).toUpperCase();
- try {
- this.compressor = CompressionType.valueOf(compressorString);
- props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase());
- } catch (Exception e) {
- throw new SemanticException(String.format("Unsupported compression:
%s", compressorString));
- }
- }
- }
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index c59aab6b00..6c25ddd637 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -301,6 +301,7 @@ public class IoTDBSqlVisitor extends
IoTDBSqlParserBaseVisitor<Operator> {
}
}
createTimeSeriesOperator.setProps(props);
+ checkPropsInCreateTimeSeries(createTimeSeriesOperator);
if (ctx.tagClause() != null) {
parseTagClause(ctx.tagClause(), createTimeSeriesOperator);
}
@@ -309,6 +310,66 @@ public class IoTDBSqlVisitor extends
IoTDBSqlParserBaseVisitor<Operator> {
}
}
+ /** check and set datatype, encoding, compressor */
+ private void checkPropsInCreateTimeSeries(CreateTimeSeriesOperator
createTimeSeriesOperator) {
+ Map<String, String> props = createTimeSeriesOperator.getProps();
+ if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase())) {
+ String datatypeString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesOperator.setDataType(TSDataType.valueOf(datatypeString));
+ props.remove(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(String.format("Unsupported datatype: %s",
datatypeString));
+ }
+ }
+ if (createTimeSeriesOperator.getDataType() == null) {
+ throw new SemanticException("datatype must be declared");
+ }
+
+ final IoTDBDescriptor ioTDBDescriptor = IoTDBDescriptor.getInstance();
+ createTimeSeriesOperator.setEncoding(
+
ioTDBDescriptor.getDefaultEncodingByType(createTimeSeriesOperator.getDataType()));
+ if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase())) {
+ String encodingString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesOperator.setEncoding(TSEncoding.valueOf(encodingString));
+ props.remove(IoTDBConstant.COLUMN_TIMESERIES_ENCODING.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(String.format("Unsupported encoding: %s",
encodingString));
+ }
+ }
+
+ createTimeSeriesOperator.setCompressor(
+ TSFileDescriptor.getInstance().getConfig().getCompressor());
+ if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase())) {
+ String compressionString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesOperator.setCompressor(CompressionType.valueOf(compressionString));
+
props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSION.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(
+ String.format("Unsupported compression: %s", compressionString));
+ }
+ } else if (props != null
+ &&
props.containsKey(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase())) {
+ String compressorString =
+
props.get(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase()).toUpperCase();
+ try {
+
createTimeSeriesOperator.setCompressor(CompressionType.valueOf(compressorString));
+ props.remove(IoTDBConstant.COLUMN_TIMESERIES_COMPRESSOR.toLowerCase());
+ } catch (Exception e) {
+ throw new SemanticException(String.format("Unsupported compression:
%s", compressorString));
+ }
+ }
+ createTimeSeriesOperator.setProps(props);
+ }
+
public void parseAttributeClauses(
IoTDBSqlParser.AttributeClausesContext ctx,
CreateAlignedTimeSeriesOperator createAlignedTimeSeriesOperator) {
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java
index d7ddeadb42..3013966201 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalChecker.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.db.qp.logical.Operator;
import org.apache.iotdb.db.qp.logical.crud.QueryOperator;
import org.apache.iotdb.db.qp.logical.crud.SelectIntoOperator;
import org.apache.iotdb.db.qp.logical.sys.CreateContinuousQueryOperator;
-import org.apache.iotdb.db.qp.logical.sys.CreateTimeSeriesOperator;
public class LogicalChecker {
@@ -43,9 +42,5 @@ public class LogicalChecker {
if (operator instanceof CreateContinuousQueryOperator) {
((CreateContinuousQueryOperator) operator).getQueryOperator().check();
}
-
- if (operator instanceof CreateTimeSeriesOperator) {
- ((CreateTimeSeriesOperator) operator).check();
- }
}
}