This is an automated email from the ASF dual-hosted git repository.
zyk 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 521e166c4f4 Fix delete data from alias series (#10118)
521e166c4f4 is described below
commit 521e166c4f40bb8119108321fe8477522220bb73
Author: Marcos_Zyk <[email protected]>
AuthorDate: Mon Jun 12 08:46:54 2023 +0800
Fix delete data from alias series (#10118)
---
.../iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java | 53 ++++++++++++++++------
1 file changed, 40 insertions(+), 13 deletions(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java
index 8717f18e495..dc0775633ae 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java
@@ -50,6 +50,7 @@ import
org.apache.iotdb.db.exception.metadata.view.UnsupportedViewException;
import org.apache.iotdb.db.exception.sql.MeasurementNotExistException;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
+import org.apache.iotdb.db.metadata.MetadataConstant;
import org.apache.iotdb.db.metadata.template.Template;
import org.apache.iotdb.db.mpp.common.MPPQueryContext;
import org.apache.iotdb.db.mpp.common.header.ColumnHeader;
@@ -158,6 +159,7 @@ import
org.apache.iotdb.tsfile.read.filter.PredicateRemoveNotRewriter;
import org.apache.iotdb.tsfile.read.filter.basic.Filter;
import org.apache.iotdb.tsfile.read.filter.factory.FilterFactory;
import org.apache.iotdb.tsfile.utils.Pair;
+import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
import org.apache.thrift.TException;
@@ -2884,23 +2886,48 @@ public class AnalyzeVisitor extends
StatementVisitor<Analysis, MPPQueryContext>
}
ISchemaTree schemaTree = schemaFetcher.fetchSchema(patternTree, context);
- analysis.setSchemaTree(schemaTree);
-
- Map<String, List<DataPartitionQueryParam>> sgNameToQueryParamsMap = new
HashMap<>();
-
Set<String> deduplicatedDevicePaths = new HashSet<>();
- for (String devicePattern : patternTree.getAllDevicePatterns()) {
- try {
- schemaTree
- .getMatchedDevices(new PartialPath(devicePattern))
- .forEach(
- deviceSchemaInfo ->
-
deduplicatedDevicePaths.add(deviceSchemaInfo.getDevicePath().getFullPath()));
- } catch (IllegalPathException ignored) {
- // won't happen
+ if (schemaTree.hasLogicalViewMeasurement()) {
+ updateSchemaTreeByViews(analysis, schemaTree);
+
+ Set<PartialPath> deletePatternSet = new
HashSet<>(deleteDataStatement.getPathList());
+ IMeasurementSchema measurementSchema;
+ LogicalViewSchema logicalViewSchema;
+ PartialPath sourcePathOfAliasSeries;
+ for (MeasurementPath measurementPath :
+
schemaTree.searchMeasurementPaths(MetadataConstant.ALL_MATCH_PATTERN).left) {
+ measurementSchema = measurementPath.getMeasurementSchema();
+ if (measurementSchema.isLogicalView()) {
+ logicalViewSchema = (LogicalViewSchema) measurementSchema;
+ if (logicalViewSchema.isWritable()) {
+ sourcePathOfAliasSeries =
logicalViewSchema.getSourcePathIfWritable();
+ deletePatternSet.add(sourcePathOfAliasSeries);
+ deduplicatedDevicePaths.add(sourcePathOfAliasSeries.getDevice());
+ } else {
+ deletePatternSet.remove(measurementPath);
+ }
+ } else {
+ deduplicatedDevicePaths.add(measurementPath.getDevice());
+ }
+ }
+ deleteDataStatement.setPathList(new ArrayList<>(deletePatternSet));
+ } else {
+ for (String devicePattern : patternTree.getAllDevicePatterns()) {
+ try {
+ schemaTree
+ .getMatchedDevices(new PartialPath(devicePattern))
+ .forEach(
+ deviceSchemaInfo ->
+
deduplicatedDevicePaths.add(deviceSchemaInfo.getDevicePath().getFullPath()));
+ } catch (IllegalPathException ignored) {
+ // won't happen
+ }
}
}
+ analysis.setSchemaTree(schemaTree);
+
+ Map<String, List<DataPartitionQueryParam>> sgNameToQueryParamsMap = new
HashMap<>();
deduplicatedDevicePaths.forEach(
devicePath -> {