You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/04/14 08:49:13 UTC
[iotdb] 01/01: resolve conflicts
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty-mpp
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 1416c60b2d711fe00bfcae8aadd4e8dd52781a3e
Merge: 014536af0f 976d041b76
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Thu Apr 14 16:49:03 2022 +0800
resolve conflicts
.../resources/conf/iotdb-confignode.properties | 12 +-
.../iotdb/confignode/cli/TemporaryClient.java | 199 +++++++++
.../iotdb/confignode/conf/ConfigNodeConf.java | 11 +
.../confignode/conf/ConfigNodeDescriptor.java | 5 +
.../consensus/response/DataPartitionDataSet.java | 23 +-
.../consensus/response/SchemaPartitionDataSet.java | 23 +-
.../iotdb/confignode/manager/DataNodeManager.java | 3 +
.../iotdb/confignode/manager/RegionManager.java | 29 +-
.../persistence/DataNodeInfoPersistence.java | 11 +
.../iotdb/confignode/cli/TemporaryClientDemo.java | 55 +++
.../db/integration/IoTDBRecoverUnclosedIT.java | 17 +-
.../iotdb/commons/cluster/DataNodeLocation.java | 4 +
.../iotdb/commons/partition/DataPartition.java | 22 +-
.../iotdb/commons/partition/RegionReplicaSet.java | 42 +-
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 3 +-
.../iotdb/db/metadata/logfile/MLogTxtWriter.java | 11 +-
.../apache/iotdb/db/mpp/common/PlanFragmentId.java | 4 +-
.../iotdb/db/mpp/common/header/HeaderConstant.java | 90 ++++
.../db/mpp/common/schematree/PathPatternTree.java | 12 +
.../iotdb/db/mpp/common/schematree/SchemaTree.java | 13 +
.../execution/{ => config}/ConfigExecution.java | 17 +-
.../db/mpp/execution/{ => config}/IConfigTask.java | 2 +-
.../execution/{ => config}/SampleConfigTask.java | 2 +-
.../mpp/execution/config/SetStorageGroupTask.java | 75 ++++
.../apache/iotdb/db/mpp/sql/analyze/Analyzer.java | 484 +++++++++++----------
.../mpp/sql/analyze/ClusterPartitionFetcher.java | 205 ++++++++-
.../mpp/sql/analyze/FakePartitionFetcherImpl.java | 30 +-
.../db/mpp/sql/analyze/IPartitionFetcher.java | 20 +-
.../sql/analyze/StandalonePartitionFetcher.java | 23 +-
.../apache/iotdb/db/mpp/sql/parser/ASTVisitor.java | 21 +
.../db/mpp/sql/planner/DistributionPlanner.java | 20 +-
.../iotdb/db/mpp/sql/planner/LogicalPlanner.java | 1 -
.../db/mpp/sql/planner/plan/FragmentInstance.java | 24 +-
.../plan/SimpleFragmentParallelPlanner.java | 9 +-
.../planner/plan/WriteFragmentParallelPlanner.java | 70 +++
.../planner/plan/node/SimplePlanNodeRewriter.java | 4 +
.../planner/plan/node/WritePlanNode.java} | 18 +-
.../plan/node/source/SeriesAggregateScanNode.java | 3 +-
.../planner/plan/node/source/SeriesScanNode.java | 3 +-
.../plan/node/write/InsertMultiTabletsNode.java | 9 +-
.../sql/planner/plan/node/write/InsertNode.java | 12 +-
.../sql/planner/plan/node/write/InsertRowNode.java | 3 +-
.../planner/plan/node/write/InsertRowsNode.java | 3 +-
.../plan/node/write/InsertRowsOfOneDeviceNode.java | 3 +-
.../planner/plan/node/write/InsertTabletNode.java | 5 +-
.../db/mpp/sql/statement/StatementVisitor.java | 20 +-
.../db/mpp/sql/statement/crud/QueryStatement.java | 4 +-
.../metadata/SetStorageGroupStatement.java} | 23 +-
.../metadata/ShowStorageGroupStatement.java} | 24 +-
.../java/org/apache/iotdb/db/service/DataNode.java | 8 +
.../apache/iotdb/db/service/IoTDBShutdownHook.java | 6 +-
.../thrift/impl/DataNodeManagementServiceImpl.java | 14 +-
.../apache/iotdb/db/utils/EnvironmentUtils.java | 2 -
.../db/mpp/sql/plan/DistributionPlannerTest.java | 87 +++-
.../db/mpp/sql/plan/FragmentInstanceSerdeTest.java | 26 +-
.../iotdb/db/mpp/sql/plan/LogicalPlannerTest.java | 2 +
.../iotdb/db/service/InternalServiceImplTest.java | 9 +-
.../src/main/thrift/confignode.thrift | 7 +-
58 files changed, 1446 insertions(+), 441 deletions(-)
diff --cc server/src/main/java/org/apache/iotdb/db/mpp/execution/config/ConfigExecution.java
index c9cb515e71,2d158c4856..2e2c31d59c
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/config/ConfigExecution.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/config/ConfigExecution.java
@@@ -17,12 -17,14 +17,16 @@@
* under the License.
*/
- package org.apache.iotdb.db.mpp.execution;
+ package org.apache.iotdb.db.mpp.execution.config;
import org.apache.iotdb.db.mpp.common.MPPQueryContext;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+ import org.apache.iotdb.db.mpp.execution.ExecutionResult;
+ import org.apache.iotdb.db.mpp.execution.IQueryExecution;
+ import org.apache.iotdb.db.mpp.execution.QueryStateMachine;
+import org.apache.iotdb.db.mpp.sql.analyze.QueryType;
import org.apache.iotdb.db.mpp.sql.statement.Statement;
+ import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
import org.apache.iotdb.rpc.RpcUtils;
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.tsfile.exception.NotImplementedException;
diff --cc server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java
index 29090cf0bc,3e205637c0..d3c399be92
--- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java
@@@ -179,282 -176,79 +177,296 @@@ public class Analyzer
return analysis;
}
- @Override
- public Analysis visitCreateTimeseries(
- CreateTimeSeriesStatement createTimeSeriesStatement, MPPQueryContext context) {
- if (createTimeSeriesStatement.getTags() != null
- && !createTimeSeriesStatement.getTags().isEmpty()
- && createTimeSeriesStatement.getAttributes() != null
- && !createTimeSeriesStatement.getAttributes().isEmpty()) {
- for (String tagKey : createTimeSeriesStatement.getTags().keySet()) {
- if (createTimeSeriesStatement.getAttributes().containsKey(tagKey)) {
- throw new SemanticException(
- String.format(
- "Tag and attribute shouldn't have the same property key [%s]", tagKey));
- }
- }
- }
- Analysis analysis = new Analysis();
- analysis.setStatement(createTimeSeriesStatement);
-
- String devicePath = createTimeSeriesStatement.getPath().getDevice();
- analysis.setSchemaPartitionInfo(partitionFetcher.fetchSchemaPartitionInfo(devicePath));
- return analysis;
- }
-
- @Override
- public Analysis visitCreateAlignedTimeseries(
- CreateAlignedTimeSeriesStatement createAlignedTimeSeriesStatement,
- MPPQueryContext context) {
- List<String> measurements = createAlignedTimeSeriesStatement.getMeasurements();
- Set<String> measurementsSet = new HashSet<>(measurements);
- if (measurementsSet.size() < measurements.size()) {
- throw new SQLParserException(
- "Measurement under an aligned device is not allowed to have the same measurement name");
- }
-
- Analysis analysis = new Analysis();
- analysis.setStatement(createAlignedTimeSeriesStatement);
-
- String devicePath = createAlignedTimeSeriesStatement.getDevicePath().getFullPath();
- analysis.setSchemaPartitionInfo(partitionFetcher.fetchSchemaPartitionInfo(devicePath));
- return analysis;
- }
-
- @Override
- public Analysis visitAlterTimeseries(
- AlterTimeSeriesStatement alterTimeSeriesStatement, MPPQueryContext context) {
- Analysis analysis = new Analysis();
- analysis.setStatement(alterTimeSeriesStatement);
-
- String devicePath = alterTimeSeriesStatement.getPath().getDevice();
- analysis.setSchemaPartitionInfo(partitionFetcher.fetchSchemaPartitionInfo(devicePath));
- return analysis;
- }
-
- @Override
- public Analysis visitInsertTablet(
- InsertTabletStatement insertTabletStatement, MPPQueryContext context) {
- context.setQueryType(QueryType.WRITE);
- DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
- dataPartitionQueryParam.setTimePartitionSlotList(
- insertTabletStatement.getTimePartitionSlots());
- dataPartitionQueryParam.setDevicePath(insertTabletStatement.getDevicePath().getFullPath());
- PartitionInfo partitionInfo = partitionFetcher.fetchPartitionInfo(dataPartitionQueryParam);
-
- SchemaTree schemaTree =
- IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled()
- ? schemaFetcher.fetchSchemaWithAutoCreate(
- insertTabletStatement.getDevicePath(),
- insertTabletStatement.getMeasurements(),
- insertTabletStatement.getDataTypes(),
- insertTabletStatement.isAligned())
- : schemaFetcher.fetchSchema(
- new PathPatternTree(
- insertTabletStatement.getDevicePath(),
- insertTabletStatement.getMeasurements()));
-
- Analysis analysis = new Analysis();
- analysis.setSchemaTree(schemaTree);
-
- if (!insertTabletStatement.checkDataType(schemaTree)) {
- throw new SemanticException("Data type mismatch");
- }
- analysis.setStatement(insertTabletStatement);
- analysis.setDataPartitionInfo(partitionInfo.getDataPartitionInfo());
- analysis.setSchemaPartitionInfo(partitionInfo.getSchemaPartitionInfo());
- return analysis;
- }
-
+ @Override
+ public Analysis visitInsertRow(InsertRowStatement insertRowStatement, MPPQueryContext context) {
- context.setQueryType(QueryType.WRITE);
- DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
- dataPartitionQueryParam.setDevicePath(insertRowStatement.getDevicePath().getFullPath());
- dataPartitionQueryParam.setTimePartitionSlotList(insertRowStatement.getTimePartitionSlots());
- PartitionInfo partitionInfo = partitionFetcher.fetchPartitionInfo(dataPartitionQueryParam);
-
++ // TODO remove duplicate
+ SchemaTree schemaTree =
- IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled()
- ? schemaFetcher.fetchSchemaWithAutoCreate(
- insertRowStatement.getDevicePath(),
- insertRowStatement.getMeasurements(),
- insertRowStatement.getDataTypes(),
- insertRowStatement.isAligned())
- : schemaFetcher.fetchSchema(
- new PathPatternTree(
- insertRowStatement.getDevicePath(), insertRowStatement.getMeasurements()));
-
- Analysis analysis = new Analysis();
- analysis.setSchemaTree(schemaTree);
++ schemaFetcher.fetchSchemaWithAutoCreate(
++ insertRowStatement.getDevicePath(),
++ insertRowStatement.getMeasurements(),
++ insertRowStatement.getDataTypes(),
++ insertRowStatement.isAligned());
+
+ try {
+ insertRowStatement.transferType(schemaTree);
+ } catch (QueryProcessException e) {
+ throw new SemanticException(e.getMessage());
+ }
+
+ if (!insertRowStatement.checkDataType(schemaTree)) {
+ throw new SemanticException("Data type mismatch");
+ }
+
++ Map<String, List<DataPartitionQueryParam>> sgNameToQueryParamsMap = new HashMap<>();
++ DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
++ dataPartitionQueryParam.setDevicePath(insertRowStatement.getDevicePath().getFullPath());
++ dataPartitionQueryParam.setTimePartitionSlotList(insertRowStatement.getTimePartitionSlots());
++ sgNameToQueryParamsMap.put(
++ schemaTree.getBelongedStorageGroup(insertRowStatement.getDevicePath()),
++ Collections.singletonList(dataPartitionQueryParam));
++ DataPartition dataPartition;
++ try {
++ dataPartition = partitionFetcher.getDataPartition(sgNameToQueryParamsMap);
++ } catch (StatementAnalyzeException e) {
++ throw new SemanticException("An error occurred when fetching data partition infos");
++ }
++
++ Analysis analysis = new Analysis();
++ analysis.setSchemaTree(schemaTree);
+ analysis.setStatement(insertRowStatement);
- analysis.setDataPartitionInfo(partitionInfo.getDataPartitionInfo());
- analysis.setSchemaPartitionInfo(partitionInfo.getSchemaPartitionInfo());
++ analysis.setDataPartitionInfo(dataPartition);
+
+ return analysis;
+ }
+
+ @Override
+ public Analysis visitInsertRows(
+ InsertRowsStatement insertRowsStatement, MPPQueryContext context) {
+ // TODO remove duplicate
- context.setQueryType(QueryType.WRITE);
- List<DataPartitionQueryParam> dataPartitionQueryParams = new ArrayList<>();
- for (InsertRowStatement insertRowStatement :
- insertRowsStatement.getInsertRowStatementList()) {
- DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
- dataPartitionQueryParam.setDevicePath(insertRowStatement.getDevicePath().getFullPath());
- dataPartitionQueryParam.setTimePartitionSlotList(
- insertRowStatement.getTimePartitionSlots());
- dataPartitionQueryParams.add(dataPartitionQueryParam);
- }
-
- PartitionInfo partitionInfo = partitionFetcher.fetchPartitionInfos(dataPartitionQueryParams);
-
- SchemaTree schemaTree = null;
- if (IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled()) {
- schemaTree =
- schemaFetcher.fetchSchemaListWithAutoCreate(
- insertRowsStatement.getDevicePaths(),
- insertRowsStatement.getMeasurementsList(),
- insertRowsStatement.getDataTypesList(),
- insertRowsStatement.getAlignedList());
- } else {
- PathPatternTree patternTree = new PathPatternTree();
- for (InsertRowStatement insertRowStatement :
- insertRowsStatement.getInsertRowStatementList()) {
- patternTree.appendPaths(
- insertRowStatement.getDevicePath(),
- Arrays.asList(insertRowStatement.getMeasurements()));
- }
- schemaFetcher.fetchSchema(patternTree);
- }
- Analysis analysis = new Analysis();
- analysis.setSchemaTree(schemaTree);
++ SchemaTree schemaTree =
++ schemaFetcher.fetchSchemaListWithAutoCreate(
++ insertRowsStatement.getDevicePaths(),
++ insertRowsStatement.getMeasurementsList(),
++ insertRowsStatement.getDataTypesList(),
++ insertRowsStatement.getAlignedList());
+
+ try {
+ insertRowsStatement.transferType(schemaTree);
+ } catch (QueryProcessException e) {
+ throw new SemanticException(e.getMessage());
+ }
+
+ if (!insertRowsStatement.checkDataType(schemaTree)) {
+ throw new SemanticException("Data type mismatch");
+ }
+
++ Map<String, List<DataPartitionQueryParam>> sgNameToQueryParamsMap = new HashMap<>();
++ for (InsertRowStatement insertRowStatement :
++ insertRowsStatement.getInsertRowStatementList()) {
++ DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
++ dataPartitionQueryParam.setDevicePath(insertRowStatement.getDevicePath().getFullPath());
++ dataPartitionQueryParam.setTimePartitionSlotList(
++ insertRowStatement.getTimePartitionSlots());
++ sgNameToQueryParamsMap
++ .computeIfAbsent(
++ schemaTree.getBelongedStorageGroup(insertRowStatement.getDevicePath()),
++ key -> new ArrayList<>())
++ .add(dataPartitionQueryParam);
++ }
++ DataPartition dataPartition;
++ try {
++ dataPartition = partitionFetcher.getDataPartition(sgNameToQueryParamsMap);
++ } catch (StatementAnalyzeException e) {
++ throw new SemanticException("An error occurred when fetching data partition infos");
++ }
++
++ Analysis analysis = new Analysis();
++ analysis.setSchemaTree(schemaTree);
+ analysis.setStatement(insertRowsStatement);
- analysis.setDataPartitionInfo(partitionInfo.getDataPartitionInfo());
- analysis.setSchemaPartitionInfo(partitionInfo.getSchemaPartitionInfo());
++ analysis.setDataPartitionInfo(dataPartition);
+
+ return analysis;
+ }
+
+ @Override
+ public Analysis visitInsertMultiTablets(
+ InsertMultiTabletsStatement insertMultiTabletsStatement, MPPQueryContext context) {
+ context.setQueryType(QueryType.WRITE);
+ // TODO remove duplicate
- List<DataPartitionQueryParam> dataPartitionQueryParams = new ArrayList<>();
++ SchemaTree schemaTree =
++ schemaFetcher.fetchSchemaListWithAutoCreate(
++ insertMultiTabletsStatement.getDevicePaths(),
++ insertMultiTabletsStatement.getMeasurementsList(),
++ insertMultiTabletsStatement.getDataTypesList(),
++ insertMultiTabletsStatement.getAlignedList());
++
++ if (!insertMultiTabletsStatement.checkDataType(schemaTree)) {
++ throw new SemanticException("Data type mismatch");
++ }
++
++ Map<String, List<DataPartitionQueryParam>> sgNameToQueryParamsMap = new HashMap<>();
+ for (InsertTabletStatement insertTabletStatement :
+ insertMultiTabletsStatement.getInsertTabletStatementList()) {
+ DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
+ dataPartitionQueryParam.setDevicePath(insertTabletStatement.getDevicePath().getFullPath());
+ dataPartitionQueryParam.setTimePartitionSlotList(
+ insertTabletStatement.getTimePartitionSlots());
- dataPartitionQueryParams.add(dataPartitionQueryParam);
++ sgNameToQueryParamsMap
++ .computeIfAbsent(
++ schemaTree.getBelongedStorageGroup(insertTabletStatement.getDevicePath()),
++ key -> new ArrayList<>())
++ .add(dataPartitionQueryParam);
+ }
-
- PartitionInfo partitionInfo = partitionFetcher.fetchPartitionInfos(dataPartitionQueryParams);
-
- SchemaTree schemaTree = null;
- if (IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled()) {
- schemaTree =
- schemaFetcher.fetchSchemaListWithAutoCreate(
- insertMultiTabletsStatement.getDevicePaths(),
- insertMultiTabletsStatement.getMeasurementsList(),
- insertMultiTabletsStatement.getDataTypesList(),
- insertMultiTabletsStatement.getAlignedList());
- } else {
- PathPatternTree patternTree = new PathPatternTree();
- for (InsertTabletStatement insertTabletStatement :
- insertMultiTabletsStatement.getInsertTabletStatementList()) {
- patternTree.appendPaths(
- insertTabletStatement.getDevicePath(),
- Arrays.asList(insertTabletStatement.getMeasurements()));
- }
- schemaFetcher.fetchSchema(patternTree);
++ DataPartition dataPartition;
++ try {
++ dataPartition = partitionFetcher.getDataPartition(sgNameToQueryParamsMap);
++ } catch (StatementAnalyzeException e) {
++ throw new SemanticException("An error occurred when fetching data partition infos");
+ }
++
+ Analysis analysis = new Analysis();
+ analysis.setSchemaTree(schemaTree);
-
- if (!insertMultiTabletsStatement.checkDataType(schemaTree)) {
- throw new SemanticException("Data type mismatch");
- }
+ analysis.setStatement(insertMultiTabletsStatement);
- analysis.setDataPartitionInfo(partitionInfo.getDataPartitionInfo());
- analysis.setSchemaPartitionInfo(partitionInfo.getSchemaPartitionInfo());
++ analysis.setDataPartitionInfo(dataPartition);
+
+ return analysis;
+ }
+
+ @Override
+ public Analysis visitInsertRowsOfOneDevice(
+ InsertRowsOfOneDeviceStatement insertRowsOfOneDeviceStatement, MPPQueryContext context) {
- context.setQueryType(QueryType.WRITE);
++ // TODO remove duplicate
++ SchemaTree schemaTree =
++ schemaFetcher.fetchSchemaWithAutoCreate(
++ insertRowsOfOneDeviceStatement.getDevicePath(),
++ insertRowsOfOneDeviceStatement.getMeasurements(),
++ insertRowsOfOneDeviceStatement.getDataTypes(),
++ insertRowsOfOneDeviceStatement.isAligned());
++
++ try {
++ insertRowsOfOneDeviceStatement.transferType(schemaTree);
++ } catch (QueryProcessException e) {
++ throw new SemanticException(e.getMessage());
++ }
++
++ if (!insertRowsOfOneDeviceStatement.checkDataType(schemaTree)) {
++ throw new SemanticException("Data type mismatch");
++ }
++
++ Map<String, List<DataPartitionQueryParam>> sgNameToQueryParamsMap = new HashMap<>();
+ DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
+ dataPartitionQueryParam.setDevicePath(
+ insertRowsOfOneDeviceStatement.getDevicePath().getFullPath());
+ dataPartitionQueryParam.setTimePartitionSlotList(
+ insertRowsOfOneDeviceStatement.getTimePartitionSlots());
++ sgNameToQueryParamsMap.put(
++ schemaTree.getBelongedStorageGroup(insertRowsOfOneDeviceStatement.getDevicePath()),
++ Collections.singletonList(dataPartitionQueryParam));
++ DataPartition dataPartition;
++ try {
++ dataPartition = partitionFetcher.getDataPartition(sgNameToQueryParamsMap);
++ } catch (StatementAnalyzeException e) {
++ throw new SemanticException("An error occurred when fetching data partition infos");
++ }
+
- PartitionInfo partitionInfo = partitionFetcher.fetchPartitionInfo(dataPartitionQueryParam);
-
- SchemaTree schemaTree = null;
- if (IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled()) {
- schemaTree =
- schemaFetcher.fetchSchemaWithAutoCreate(
- insertRowsOfOneDeviceStatement.getDevicePath(),
- insertRowsOfOneDeviceStatement.getMeasurements(),
- insertRowsOfOneDeviceStatement.getDataTypes(),
- insertRowsOfOneDeviceStatement.isAligned());
- } else {
- PathPatternTree patternTree = new PathPatternTree();
- for (InsertRowStatement insertRowStatement :
- insertRowsOfOneDeviceStatement.getInsertRowStatementList()) {
- patternTree.appendPaths(
- insertRowStatement.getDevicePath(),
- Arrays.asList(insertRowStatement.getMeasurements()));
- }
- schemaFetcher.fetchSchema(patternTree);
++ Analysis analysis = new Analysis();
++ analysis.setSchemaTree(schemaTree);
++ analysis.setStatement(insertRowsOfOneDeviceStatement);
++ analysis.setDataPartitionInfo(dataPartition);
++
++ return analysis;
++ }
++
++ @Override
++ public Analysis visitInsertTablet(
++ InsertTabletStatement insertTabletStatement, MPPQueryContext context) {
++ context.setQueryType(QueryType.WRITE);
++ SchemaTree schemaTree =
++ schemaFetcher.fetchSchemaWithAutoCreate(
++ insertTabletStatement.getDevicePath(),
++ insertTabletStatement.getMeasurements(),
++ insertTabletStatement.getDataTypes(),
++ insertTabletStatement.isAligned());
++
++ if (!insertTabletStatement.checkDataType(schemaTree)) {
++ throw new SemanticException("Data type mismatch");
+ }
++
++ Map<String, List<DataPartitionQueryParam>> sgNameToQueryParamsMap = new HashMap<>();
++ DataPartitionQueryParam dataPartitionQueryParam = new DataPartitionQueryParam();
++ dataPartitionQueryParam.setDevicePath(insertTabletStatement.getDevicePath().getFullPath());
++ dataPartitionQueryParam.setTimePartitionSlotList(
++ insertTabletStatement.getTimePartitionSlots());
++ sgNameToQueryParamsMap.put(
++ schemaTree.getBelongedStorageGroup(insertTabletStatement.getDevicePath()),
++ Collections.singletonList(dataPartitionQueryParam));
++ DataPartition dataPartition;
++ try {
++ dataPartition = partitionFetcher.getDataPartition(sgNameToQueryParamsMap);
++ } catch (StatementAnalyzeException e) {
++ throw new SemanticException("An error occurred when fetching data partition infos");
++ }
++
+ Analysis analysis = new Analysis();
+ analysis.setSchemaTree(schemaTree);
++ analysis.setStatement(insertTabletStatement);
++ analysis.setDataPartitionInfo(dataPartition);
++ return analysis;
++ }
+
+ @Override
+ public Analysis visitCreateTimeseries(
+ CreateTimeSeriesStatement createTimeSeriesStatement, MPPQueryContext context) {
+ if (createTimeSeriesStatement.getTags() != null
+ && !createTimeSeriesStatement.getTags().isEmpty()
+ && createTimeSeriesStatement.getAttributes() != null
+ && !createTimeSeriesStatement.getAttributes().isEmpty()) {
+ for (String tagKey : createTimeSeriesStatement.getTags().keySet()) {
+ if (createTimeSeriesStatement.getAttributes().containsKey(tagKey)) {
+ throw new SemanticException(
+ String.format(
+ "Tag and attribute shouldn't have the same property key [%s]", tagKey));
+ }
+ }
+ }
+ Analysis analysis = new Analysis();
+ analysis.setStatement(createTimeSeriesStatement);
+
+ SchemaPartition schemaPartitionInfo;
try {
- insertRowsOfOneDeviceStatement.transferType(schemaTree);
- } catch (QueryProcessException e) {
- throw new SemanticException(e.getMessage());
+ schemaPartitionInfo =
+ partitionFetcher.getSchemaPartition(
+ new PathPatternTree(createTimeSeriesStatement.getPath()));
+ } catch (StatementAnalyzeException e) {
+ throw new SemanticException("An error occurred when fetching schema partition infos");
}
+ analysis.setSchemaPartitionInfo(schemaPartitionInfo);
+ return analysis;
+ }
- if (!insertRowsOfOneDeviceStatement.checkDataType(schemaTree)) {
- throw new SemanticException("Data type mismatch");
+ @Override
+ public Analysis visitCreateAlignedTimeseries(
+ CreateAlignedTimeSeriesStatement createAlignedTimeSeriesStatement,
+ MPPQueryContext context) {
+ List<String> measurements = createAlignedTimeSeriesStatement.getMeasurements();
+ Set<String> measurementsSet = new HashSet<>(measurements);
+ if (measurementsSet.size() < measurements.size()) {
+ throw new SemanticException(
+ "Measurement under an aligned device is not allowed to have the same measurement name");
}
- analysis.setStatement(insertRowsOfOneDeviceStatement);
- analysis.setDataPartitionInfo(partitionInfo.getDataPartitionInfo());
- analysis.setSchemaPartitionInfo(partitionInfo.getSchemaPartitionInfo());
+ Analysis analysis = new Analysis();
+ analysis.setStatement(createAlignedTimeSeriesStatement);
+ SchemaPartition schemaPartitionInfo;
+ try {
+ schemaPartitionInfo =
+ partitionFetcher.getSchemaPartition(
+ new PathPatternTree(
+ createAlignedTimeSeriesStatement.getDevicePath(),
+ createAlignedTimeSeriesStatement.getMeasurements()));
+ } catch (StatementAnalyzeException e) {
+ throw new SemanticException("An error occurred when fetching schema partition infos");
+ }
+ analysis.setSchemaPartitionInfo(schemaPartitionInfo);
+ return analysis;
+ }
+
+ @Override
+ public Analysis visitAlterTimeseries(
+ AlterTimeSeriesStatement alterTimeSeriesStatement, MPPQueryContext context) {
+ Analysis analysis = new Analysis();
+ analysis.setStatement(alterTimeSeriesStatement);
+
+ SchemaPartition schemaPartitionInfo;
+ try {
+ schemaPartitionInfo =
+ partitionFetcher.getSchemaPartition(
+ new PathPatternTree(alterTimeSeriesStatement.getPath()));
+ } catch (StatementAnalyzeException e) {
+ throw new SemanticException("An error occurred when fetching schema partition infos");
+ }
+ analysis.setSchemaPartitionInfo(schemaPartitionInfo);
return analysis;
}