You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/06/07 06:10:14 UTC
[iotdb] 01/01: except device if it's not exist in where clause
This is an automated email from the ASF dual-hosted git repository.
xiangweiwei pushed a commit to branch issue3361
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 777b63882c73601f3300503aa0a21bf109936905
Author: Alima777 <wx...@gmail.com>
AuthorDate: Tue Jun 7 14:09:41 2022 +0800
except device if it's not exist in where clause
---
.../sql/MeasurementNotExistException.java | 27 ++++++++++++++++++++++
.../apache/iotdb/db/mpp/plan/analyze/Analyzer.java | 20 +++++++++++++---
.../db/mpp/plan/analyze/ExpressionAnalyzer.java | 5 ++--
3 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/exception/sql/MeasurementNotExistException.java b/server/src/main/java/org/apache/iotdb/db/exception/sql/MeasurementNotExistException.java
new file mode 100644
index 0000000000..0ea1ca2a87
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/exception/sql/MeasurementNotExistException.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.exception.sql;
+
+public class MeasurementNotExistException extends SemanticException {
+
+ public MeasurementNotExistException(String message) {
+ super(message);
+ }
+}
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 8418241072..d3961e9211 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,6 +27,7 @@ import org.apache.iotdb.commons.partition.DataPartitionQueryParam;
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.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.path.MeasurementPath;
@@ -91,6 +92,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -287,9 +289,21 @@ public class Analyzer {
if (queryStatement.getWhereCondition() != null) {
Map<String, Expression> deviceToQueryFilter = new HashMap<>();
- for (PartialPath devicePath : deviceList) {
- Expression queryFilter =
- analyzeWhereSplitByDevice(queryStatement, devicePath, schemaTree);
+ Iterator<PartialPath> deviceIterator = deviceList.iterator();
+ while (deviceIterator.hasNext()) {
+ PartialPath devicePath = deviceIterator.next();
+ Expression queryFilter = null;
+ try {
+ queryFilter = analyzeWhereSplitByDevice(queryStatement, devicePath, schemaTree);
+ } catch (SemanticException e) {
+ if (e instanceof MeasurementNotExistException) {
+ logger.warn(e.getMessage());
+ deviceIterator.remove();
+ deviceToSourceExpressions.remove(devicePath.getFullPath());
+ continue;
+ }
+ throw e;
+ }
deviceToQueryFilter.put(devicePath.getFullPath(), queryFilter);
updateSource(
queryFilter,
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java
index 7c0a6e9a54..1b3588971e 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/ExpressionAnalyzer.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.db.mpp.plan.analyze;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.exception.sql.MeasurementNotExistException;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.metadata.path.MeasurementPath;
import org.apache.iotdb.db.mpp.common.schematree.PathPatternTree;
@@ -506,9 +507,9 @@ public class ExpressionAnalyzer {
List<MeasurementPath> noStarPaths = schemaTree.searchMeasurementPaths(concatPath).left;
if (noStarPaths.size() == 0) {
- throw new SemanticException(
+ throw new MeasurementNotExistException(
String.format(
- "ALIGN BY DEVICE: measurement '%s' does not exist in device '%s'",
+ "ALIGN BY DEVICE: Measurement '%s' does not exist in device '%s'",
measurement, devicePath));
}