You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2022/04/28 13:53:21 UTC
[iotdb] 01/01: [IOTDB-3029] The prefix path generated by the select into target sequence contains * and ** currently unchecked
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch iotdb-3029
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit d3c8af74ba907e05d589bac13dba928b014bb5b7
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Thu Apr 28 21:53:01 2022 +0800
[IOTDB-3029] The prefix path generated by the select into target sequence contains * and ** currently unchecked
---
docs/UserGuide/Process-Data/Select-Into.md | 6 +++---
docs/zh/UserGuide/Process-Data/Select-Into.md | 8 ++++----
.../apache/iotdb/db/integration/IoTDBSelectIntoIT.java | 6 +-----
.../iotdb/db/qp/logical/crud/SelectIntoOperator.java | 15 +++++++++++++++
4 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/docs/UserGuide/Process-Data/Select-Into.md b/docs/UserGuide/Process-Data/Select-Into.md
index 3e86c201b6..1754d10588 100644
--- a/docs/UserGuide/Process-Data/Select-Into.md
+++ b/docs/UserGuide/Process-Data/Select-Into.md
@@ -235,11 +235,11 @@ When the target aligned timeseries are not existed, the system will automaticall
### Other Restrictions
* The number of source series in the `select` clause and the number of target series in the `into` clause must be the same.
-* The `select *` clause is not supported.
-* The target series in the `into` clause do not need to be created in advance.
-* When the target series in the `into` clause already exist, you need to ensure that the source series in the `select` clause and the target series in the `into` clause have the same data types.
+* The `select *` and `select **` clause are not supported.
+* The target series in the `into` clause do not need to be created in advance. When the target series in the `into` clause already exist, you need to ensure that the source series in the `select` clause and the target series in the `into` clause have the same data types.
* The target series in the `into` clause must be different from each other.
* Only one prefix path of a series is allowed in the `from` clause.
+* `*` and `**` are not allowed in the `from` clause.
* Aligned Timeseries has not been supported in Time series generating function query(including UDF query)/ Arithmetic query / Nested query yet. An error message is expected if you use these types of query with Aligned Timeseries selected in the `select` clause.
diff --git a/docs/zh/UserGuide/Process-Data/Select-Into.md b/docs/zh/UserGuide/Process-Data/Select-Into.md
index b1ca5a8ccb..6f9afc64e6 100644
--- a/docs/zh/UserGuide/Process-Data/Select-Into.md
+++ b/docs/zh/UserGuide/Process-Data/Select-Into.md
@@ -236,12 +236,12 @@ intoPath
### 其他限制
* `select`子句中的源序列和`into`子句中的目标序列数量必须相同
-* `select`子句不支持带 `*` 查询
-* `into`子句中的目标序列不必预先创建(可使用自动创建schema功能)
-* 当`into`子句中的目标序列已存在时,您需要保证`select`子句中的源序列和`into`子句中的目标序列的数据类型一致
+* `select`子句不支持带 `*`/`**` 查询
+* `into`子句中的目标序列不必预先创建(可使用自动创建schema功能),但是当`into`子句中的目标序列已存在时,您需要保证`select`子句中的源序列和`into`子句中的目标序列的数据类型一致
* `into`子句中的目标序列必须是互不相同的
* `from`子句只允许有一列序列前缀
-* 由于时间序列生成函数查询(UDF查询)/ 数学表达式查询 / 嵌套查询 尚不支持对齐时间序列(Aligned Timeseries),所以如果您在`select`子句中使用了上述查询,并且对应操作数包含对齐时间序列,会提示错误。
+* `from`子句不支持带 `*`/`**`
+* 由于时间序列生成函数查询(UDF查询)/ 数学表达式查询 / 嵌套查询 尚不支持对齐时间序列(Aligned Timeseries),所以如果您在`select`子句中使用了上述查询,并且对应操作数包含对齐时间序列,会提示错误
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java
index 1c120ca48f..d784fc7914 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java
@@ -543,11 +543,7 @@ public class IoTDBSelectIntoIT {
statement.execute("select s1 into target from root.sg.*");
fail();
} catch (SQLException throwable) {
- assertTrue(
- throwable
- .getMessage()
- .contains(
- "the number of source paths and the number of target paths should be the same"));
+ assertTrue(throwable.getMessage().contains("* and ** are not allowed in a target path."));
}
try (Connection connection =
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/SelectIntoOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/SelectIntoOperator.java
index 09231c961a..555bf0bebb 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/SelectIntoOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/SelectIntoOperator.java
@@ -67,6 +67,9 @@ public class SelectIntoOperator extends Operator {
"select into: target paths in into clause should be different.");
}
+ checkWildcardsInPartialPaths(intoPaths);
+ checkWildcardsInPartialPaths(queryOperator.getFromComponent().getPrefixPaths());
+
if (queryOperator.isAlignByDevice()) {
throw new LogicalOperatorException("select into: align by device clauses are not supported.");
}
@@ -100,6 +103,18 @@ public class SelectIntoOperator extends Operator {
}
}
+ private void checkWildcardsInPartialPaths(List<PartialPath> paths)
+ throws LogicalOperatorException {
+ for (PartialPath path : paths) {
+ for (String node : path.getNodes()) {
+ if ("*".equals(node) || "**".equals(node)) {
+ throw new LogicalOperatorException(
+ "select into: * and ** are not allowed in a target path.");
+ }
+ }
+ }
+ }
+
public void setQueryOperator(QueryOperator queryOperator) {
this.queryOperator = queryOperator;
}