This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch force_ci/object_type
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 6f47cca0efbdb381b03135f752a42aaa87e8fb0d
Author: Caideyipi <[email protected]>
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)
    
    (cherry picked from commit b4d5b4235e12763466df989492f2d54ec0ed5b0d)
---
 .../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 7fd2bd49033..8a1a0f5468f 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 7a0c1969398..f63fd211149 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
@@ -846,6 +846,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 71b6f58f83e..517e201f3d8 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
@@ -2803,6 +2803,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 64d606ef72e..123f7dcae52 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
@@ -695,6 +695,9 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
       }
     }
 
+    if (tree.isEmpty()) {
+      throw new SemanticException("The timeSeries shall not be root.");
+    }
     return new AlterEncodingCompressorStatement(
         tree,
         encoding,

Reply via email to