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 2025/12/18 04:08:26 UTC
(iotdb) 02/06: Changed the SQL of AlterEncodingCompressor statement & banned the "root" timeSeries & handled the empty intersection path & refactored the IT (#16725)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.6
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 06ca819daca2ca7baed87def81425470621b2b0e
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Mon Nov 10 19:28:00 2025 +0800
Changed the SQL of AlterEncodingCompressor statement & banned the "root" timeSeries & handled the empty intersection path & refactored the IT (#16725)
---
.../it/schema/IoTDBAlterEncodingCompressorIT.java | 44 ++++++++++++++++------
.../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 2 +-
.../antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 | 4 ++
.../config/executor/ClusterConfigTaskExecutor.java | 5 +++
.../db/queryengine/plan/parser/ASTVisitor.java | 3 ++
5 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterEncodingCompressorIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterEncodingCompressorIT.java
index 42c0275ab35..7c9495d16eb 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterEncodingCompressorIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterEncodingCompressorIT.java
@@ -72,7 +72,15 @@ public class IoTDBAlterEncodingCompressorIT extends AbstractSchemaIT {
statement.execute("create timeSeries root.vehicle.wind.a int32");
try {
- statement.execute("alter timeSeries root.nonExist.** set encoding=PLAIN");
+ statement.execute("alter timeSeries root set STORAGE_PROPERTIES encoding=PLAIN");
+ fail();
+ } catch (final SQLException e) {
+ Assert.assertEquals("701: The timeSeries shall not be root.", e.getMessage());
+ }
+
+ try {
+ statement.execute(
+ "alter timeSeries root.nonExist.** set STORAGE_PROPERTIES encoding=PLAIN");
fail();
} catch (final SQLException e) {
Assert.assertEquals(
@@ -81,41 +89,47 @@ public class IoTDBAlterEncodingCompressorIT extends AbstractSchemaIT {
}
try {
- statement.execute("alter timeSeries if exists root.nonExist.** set encoding=PLAIN");
+ statement.execute(
+ "alter timeSeries if exists root.nonExist.** set STORAGE_PROPERTIES encoding=PLAIN");
} catch (final SQLException e) {
fail(
"Alter encoding & compressor shall not fail when timeSeries not exists if set if exists");
}
try {
- statement.execute("alter timeSeries if exists root.vehicle.** set encoding=aaa");
+ statement.execute(
+ "alter timeSeries if exists root.vehicle.** set STORAGE_PROPERTIES encoding=aaa");
fail();
} catch (final SQLException e) {
Assert.assertEquals("701: Unsupported encoding: AAA", e.getMessage());
}
try {
- statement.execute("alter timeSeries if exists root.vehicle.** set compressor=aaa");
+ statement.execute(
+ "alter timeSeries if exists root.vehicle.** set STORAGE_PROPERTIES compressor=aaa");
fail();
} catch (final SQLException e) {
Assert.assertEquals("701: Unsupported compressor: AAA", e.getMessage());
}
try {
- statement.execute("alter timeSeries if exists root.vehicle.** set falseKey=aaa");
+ statement.execute(
+ "alter timeSeries if exists root.vehicle.** set STORAGE_PROPERTIES falseKey=aaa");
fail();
} catch (final SQLException e) {
Assert.assertEquals("701: property falsekey is unsupported yet.", e.getMessage());
}
try {
- statement.execute("alter timeSeries if exists root.vehicle.** set encoding=DICTIONARY");
+ statement.execute(
+ "alter timeSeries if exists root.vehicle.** set STORAGE_PROPERTIES encoding=DICTIONARY");
fail();
} catch (final SQLException e) {
Assert.assertTrue(e.getMessage().contains("encoding DICTIONARY does not support INT32"));
}
- statement.execute("alter timeSeries root.** set encoding=Plain, compressor=LZMA2");
+ statement.execute(
+ "alter timeSeries root.** set STORAGE_PROPERTIES encoding=Plain, compressor=LZMA2");
try (final ResultSet resultSet = statement.executeQuery("SHOW TIMESERIES")) {
while (resultSet.next()) {
@@ -133,17 +147,18 @@ public class IoTDBAlterEncodingCompressorIT extends AbstractSchemaIT {
EnvFactory.getEnv().getConnection("IoTDBUser", "!@#$!dfdfzvd343");
final Statement statement = connection.createStatement()) {
try {
- statement.execute("alter timeSeries root.vechile.** set encoding=PLAIN, compressor=LZMA2");
+ statement.execute(
+ "alter timeSeries root.vehicle.** set STORAGE_PROPERTIES encoding=PLAIN, compressor=LZMA2");
fail();
} catch (final SQLException e) {
Assert.assertEquals(
- "803: No permissions for this operation, please add privilege WRITE_SCHEMA on [root.vechile.**]",
+ "803: No permissions for this operation, please add privilege WRITE_SCHEMA on [root.vehicle.**]",
e.getMessage());
}
try {
statement.execute(
- "alter timeSeries root.vechile.wind.a, root.__audit.** set encoding=PLAIN, compressor=LZMA2");
+ "alter timeSeries root.vehicle.wind.a, root.__audit.** set STORAGE_PROPERTIES encoding=PLAIN, compressor=LZMA2");
fail();
} catch (final SQLException e) {
Assert.assertEquals(
@@ -153,10 +168,17 @@ public class IoTDBAlterEncodingCompressorIT extends AbstractSchemaIT {
try {
statement.execute(
- "alter timeSeries if permitted root.vehicle.**, root.__audit.** set encoding=GORILLA, compressor=GZIP");
+ "alter timeSeries if permitted root.vehicle.**, root.__audit.** set STORAGE_PROPERTIES encoding=GORILLA, compressor=GZIP");
} catch (final SQLException e) {
fail("Alter encoding & compressor shall not fail when no privileges if set if permitted");
}
+
+ try {
+ statement.execute(
+ "alter timeSeries if permitted root.nonExist.** set STORAGE_PROPERTIES encoding=GORILLA, compressor=GZIP");
+ } catch (final SQLException e) {
+ fail("Alter encoding & compressor shall not fail if the intersected paths are empty");
+ }
}
try (final Connection connection = EnvFactory.getEnv().getConnection();
diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index 28523138e84..2ad18560796 100644
--- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -178,7 +178,7 @@ alterClause
;
alterEncodingCompressor
- : ALTER TIMESERIES (IF EXISTS)? (IF PERMITTED)? prefixPath (COMMA prefixPath)* SET attributePair (COMMA attributePair)*
+ : ALTER TIMESERIES (IF EXISTS)? (IF PERMITTED)? prefixPath (COMMA prefixPath)* SET STORAGE_PROPERTIES attributePair (COMMA attributePair)*
;
aliasClause
diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index 353463fa52b..3c12d55b6e2 100644
--- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -842,6 +842,10 @@ STOP
: S T O P
;
+STORAGE_PROPERTIES
+ : S T O R A G E '_' P R O P E R T I E S
+ ;
+
SUBSCRIPTION
: S U B S C R I P T I O N
;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index 7df5fa2fb60..1d9072f9401 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -2610,6 +2610,11 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor {
final String queryId,
final AlterEncodingCompressorStatement alterEncodingCompressorStatement) {
final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+ // Will only occur if no permission
+ if (alterEncodingCompressorStatement.getPatternTree().isEmpty()) {
+ future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS));
+ return future;
+ }
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
try {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
index 4fc0670dfaf..7d6d30ff321 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -694,6 +694,9 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
}
}
+ if (tree.isEmpty()) {
+ throw new SemanticException("The timeSeries shall not be root.");
+ }
return new AlterEncodingCompressorStatement(
tree,
encoding,