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 15:32:34 UTC
[iotdb] branch master updated: [IOTDB-3029] The prefix path generated by the select into target sequence contains * and ** currently unchecked (#5723)
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 8f7fb57661 [IOTDB-3029] The prefix path generated by the select into target sequence contains * and ** currently unchecked (#5723)
8f7fb57661 is described below
commit 8f7fb5766131bf9f63843398dd3854d6409d7ead
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Thu Apr 28 23:32:29 2022 +0800
[IOTDB-3029] The prefix path generated by the select into target sequence contains * and ** currently unchecked (#5723)
---
docs/UserGuide/Process-Data/Select-Into.md | 6 +++---
docs/zh/UserGuide/Process-Data/Select-Into.md | 8 ++++----
.../db/integration/IoTDBDeleteStorageGroupIT.java | 24 ----------------------
.../iotdb/db/integration/IoTDBSelectIntoIT.java | 6 +-----
.../db/qp/logical/crud/SelectIntoOperator.java | 15 ++++++++++++++
5 files changed, 23 insertions(+), 36 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/IoTDBDeleteStorageGroupIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeleteStorageGroupIT.java
index 2c3700c9d1..ac5873b0b6 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeleteStorageGroupIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeleteStorageGroupIT.java
@@ -25,7 +25,6 @@ import org.apache.iotdb.itbase.category.RemoteTest;
import org.apache.iotdb.jdbc.IoTDBSQLException;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -181,27 +180,4 @@ public class IoTDBDeleteStorageGroupIT {
assertEquals(1, count);
}
}
-
- @Test
- public void testSelectIntoAndDeleteStorageGroup() throws Exception {
- try (Connection connection = EnvFactory.getEnv().getConnection();
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create schema template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)");
- statement.execute("set schema template t1 to root.sg1.d1;");
- statement.execute("create timeseries of schema template on root.sg1.d1;");
- statement.execute("show timeseries root.sg1.**;");
- statement.execute("show devices root.sg1.**;");
- statement.execute("insert into root.sg1.d1(time, temperature, status) values(1, 1, TRUE);");
- statement.execute(
- "insert into root.sg1.d1(time, temperature, status) values(2, 2, FALSE), (3, 3, TRUE);");
- statement.execute("select temperature into h1 from root.sg1.**;");
- statement.execute("select temperature,h1 from root.sg1.**;");
- statement.execute("show schema templates;");
- statement.execute("delete storage group root.**;");
- statement.execute("drop schema template t1;");
- } catch (Exception e) {
- Assert.fail();
- }
- }
}
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;
}