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

justinchen pushed a commit to branch fix-quote
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/fix-quote by this push:
     new e97352ce3db quote-fix
e97352ce3db is described below

commit e97352ce3db69a72a0d67049baa7185d8411e234
Author: Caideyipi <[email protected]>
AuthorDate: Mon Mar 2 15:13:47 2026 +0800

    quote-fix
---
 .../iotdb/relational/it/schema/IoTDBTableIT.java   | 48 +++++++++++-----------
 .../metadata/relational/ShowCreateViewTask.java    |  2 +-
 .../plan/relational/sql/parser/AstBuilder.java     | 30 +++++++++-----
 3 files changed, 45 insertions(+), 35 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
index 57d482dd1b0..aac532a9800 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
@@ -761,10 +761,10 @@ public class IoTDBTableIT {
     try (final Connection connection = EnvFactory.getEnv().getConnection();
         final Statement statement = connection.createStatement()) {
       statement.execute("create database root.another");
-      statement.execute("create database root.`重庆`.b");
-      statement.execute("create timeSeries root.`重庆`.b.c.S1 int32");
-      statement.execute("create timeSeries root.`重庆`.b.c.s2 string");
-      statement.execute("create timeSeries root.`重庆`.b.S1 int32");
+      statement.execute("create database root.`重庆`.`1`.b");
+      statement.execute("create timeSeries root.`重庆`.`1`.b.c.S1 int32");
+      statement.execute("create timeSeries root.`重庆`.`1`.b.c.s2 string");
+      statement.execute("create timeSeries root.`重庆`.`1`.b.S1 int32");
     } catch (SQLException e) {
       fail(e.getMessage());
     }
@@ -783,13 +783,13 @@ public class IoTDBTableIT {
             "701: Cannot specify view pattern to match more than one tree 
database.",
             e.getMessage());
       }
-      statement.execute("create view tree_table (tag1 tag, tag2 tag) as 
root.\"重庆\".**");
+      statement.execute("create view tree_table (tag1 tag, tag2 tag) as 
root.\"重庆\".\"1\".**");
       statement.execute("drop view tree_table");
     }
 
     try (final Connection connection = EnvFactory.getEnv().getConnection();
         final Statement statement = connection.createStatement()) {
-      statement.execute("create timeSeries root.`重庆`.b.d.s1 int32");
+      statement.execute("create timeSeries root.`重庆`.`1`.b.d.s1 int32");
     } catch (SQLException e) {
       fail(e.getMessage());
     }
@@ -800,7 +800,7 @@ public class IoTDBTableIT {
       statement.execute("use tree_view_db");
 
       try {
-        statement.execute("create view tree_table (tag1 tag, tag2 tag) as 
root.\"重庆\".**");
+        statement.execute("create view tree_table (tag1 tag, tag2 tag) as 
root.\"重庆\".\"1\".**");
         fail();
       } catch (final SQLException e) {
         final Set<String> result =
@@ -814,13 +814,13 @@ public class IoTDBTableIT {
 
     try (final Connection connection = EnvFactory.getEnv().getConnection();
         final Statement statement = connection.createStatement()) {
-      statement.execute("drop timeSeries root.`重庆`.b.d.s1");
+      statement.execute("drop timeSeries root.`重庆`.`1`.b.d.s1");
       statement.execute("create device template t1 (S1 boolean, s9 int32)");
-      statement.execute("set schema template t1 to root.`重庆`.b.d");
-      statement.execute("create timeSeries root.`重庆`.b.c.f.g.h.S1 int32");
+      statement.execute("set schema template t1 to root.`重庆`.`1`.b.d");
+      statement.execute("create timeSeries root.`重庆`.`1`.b.c.f.g.h.S1 int32");
 
       // Put schema cache
-      statement.execute("select S1, s2 from root.`重庆`.b.c");
+      statement.execute("select S1, s2 from root.`重庆`.`1`.b.c");
     } catch (SQLException e) {
       fail(e.getMessage());
     }
@@ -831,7 +831,7 @@ public class IoTDBTableIT {
       statement.execute("use tree_view_db");
 
       try {
-        statement.execute("create view tree_table (tag1 tag, tag2 tag) as 
root.\"重庆\".**");
+        statement.execute("create view tree_table (tag1 tag, tag2 tag) as 
root.\"重庆\".\"1\".**");
         fail();
       } catch (final SQLException e) {
         assertEquals(
@@ -841,7 +841,7 @@ public class IoTDBTableIT {
 
       try {
         statement.execute(
-            "create view tree_table (tag1 tag, tag2 tag, S1 field) as 
root.\"重庆\".**");
+            "create view tree_table (tag1 tag, tag2 tag, S1 field) as 
root.\"重庆\".\"1\".**");
         fail();
       } catch (final SQLException e) {
         assertEquals(
@@ -852,7 +852,7 @@ public class IoTDBTableIT {
 
     try (final Connection connection = EnvFactory.getEnv().getConnection();
         final Statement statement = connection.createStatement()) {
-      statement.execute("create timeSeries root.`重庆`.b.e.s1 int32");
+      statement.execute("create timeSeries root.`重庆`.`1`.b.e.s1 int32");
     } catch (SQLException e) {
       fail(e.getMessage());
     }
@@ -873,7 +873,7 @@ public class IoTDBTableIT {
       // Temporary
       try {
         statement.execute(
-            "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 
field, s3 boolean from S1) as root.\"重庆\".**");
+            "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 
field, s3 boolean from S1) as root.\"重庆\".\"1\".**");
         fail();
       } catch (final SQLException e) {
         assertEquals(
@@ -882,14 +882,14 @@ public class IoTDBTableIT {
 
       try {
         statement.execute(
-            "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 
field, s3 from s2, s8 field) as root.\"重庆\".**");
+            "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 
field, s3 from s2, s8 field) as root.\"重庆\".\"1\".**");
         fail();
       } catch (final SQLException e) {
         assertEquals("528: Measurements not found for s8, cannot auto detect", 
e.getMessage());
       }
 
       statement.execute(
-          "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 
field, s3 from s2) as root.\"重庆\".**");
+          "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 
field, s3 from s2) as root.\"重庆\".\"1\".**");
 
       // Cannot be written
       try {
@@ -953,7 +953,7 @@ public class IoTDBTableIT {
         final Statement statement = connection.createStatement()) {
       // Test create & replace + restrict
       statement.execute(
-          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.`重庆`.**");
+          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.`重庆`.`1`.**");
       fail();
     } catch (final SQLException e) {
       assertTrue(
@@ -974,7 +974,7 @@ public class IoTDBTableIT {
                 .getConnection("testUser", "testUser123456", 
BaseEnv.TABLE_SQL_DIALECT);
         final Statement statement = connection.createStatement()) {
       statement.execute(
-          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
+          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
       fail();
     } catch (final SQLException e) {
       assertEquals(
@@ -995,7 +995,7 @@ public class IoTDBTableIT {
                 .getConnection("testUser", "testUser123456", 
BaseEnv.TABLE_SQL_DIALECT);
         final Statement statement = connection.createStatement()) {
       statement.execute(
-          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
+          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
       fail();
     } catch (final SQLException e) {
       assertEquals(
@@ -1015,7 +1015,7 @@ public class IoTDBTableIT {
                 .getConnection("testUser", "testUser123456", 
BaseEnv.TABLE_SQL_DIALECT);
         final Statement statement = connection.createStatement()) {
       statement.execute(
-          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
+          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
       fail();
     } catch (final SQLException e) {
       assertEquals(
@@ -1035,7 +1035,7 @@ public class IoTDBTableIT {
                 .getConnection("testUser", "testUser123456", 
BaseEnv.TABLE_SQL_DIALECT);
         final Statement statement = connection.createStatement()) {
       statement.execute(
-          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
+          "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, 
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
     } catch (final SQLException e) {
       fail();
     }
@@ -1054,14 +1054,14 @@ public class IoTDBTableIT {
           statement.executeQuery("show create view view_table"),
           "View,Create View,",
           Collections.singleton(
-              "view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING 
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") 
RESTRICT WITH (ttl=100) AS root.\"重庆\".**,"));
+              "view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING 
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") 
RESTRICT WITH (ttl=100) AS root.\"重庆\".\"1\".**,"));
 
       // Can also use "show create table"
       TestUtils.assertResultSetEqual(
           statement.executeQuery("show create table view_table"),
           "View,Create View,",
           Collections.singleton(
-              "view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING 
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") 
RESTRICT WITH (ttl=100) AS root.\"重庆\".**,"));
+              "view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING 
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") 
RESTRICT WITH (ttl=100) AS root.\"重庆\".\"1\".**,"));
 
       statement.execute("create table a ()");
       try {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
index a0c8325b864..f4a8578c1e7 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
@@ -146,7 +146,7 @@ public class ShowCreateViewTask extends AbstractTableTask {
     final String[] pathNodes = 
TreeViewSchema.getPrefixPattern(table).getNodes();
     builder.append(pathNodes[0]);
     for (int i = 1; i < pathNodes.length - 1; ++i) {
-      builder.append(".\"").append(pathNodes[i]).append("\"");
+      builder.append(".\"").append(pathNodes[i].replace("`", "")).append("\"");
     }
     builder.append(".").append(pathNodes[pathNodes.length - 1]);
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
index f46b356423d..1721ad9b80d 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
 import org.apache.iotdb.commons.auth.entity.PrivilegeType;
 import org.apache.iotdb.commons.cluster.NodeStatus;
 import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.schema.cache.CacheClearOptions;
 import org.apache.iotdb.commons.schema.table.InformationSchema;
@@ -734,17 +735,26 @@ public class AstBuilder extends 
RelationalSqlBaseVisitor<Node> {
 
   private PartialPath parsePrefixPath(final 
RelationalSqlParser.PrefixPathContext ctx) {
     final List<RelationalSqlParser.NodeNameContext> nodeNames = ctx.nodeName();
-    final String[] path = new String[nodeNames.size() + 1];
-    path[0] = ctx.ROOT().getText();
+    final StringBuilder builder = new StringBuilder("root.");
     for (int i = 0; i < nodeNames.size(); i++) {
-      path[i + 1] =
-          parseNodeString(
-              nodeNames.get(i).nodeNameWithoutWildcard() != null
-                  ? ((Identifier) 
visit(nodeNames.get(i).nodeNameWithoutWildcard().identifier()))
-                      .getValue()
-                  : nodeNames.get(i).getText());
-    }
-    return new PartialPath(path);
+      if (nodeNames.get(i).nodeNameWithoutWildcard() != null) {
+        builder
+            .append("`")
+            .append(
+                parseNodeString(
+                    ((Identifier) 
visit(nodeNames.get(i).nodeNameWithoutWildcard().identifier()))
+                        .getValue()))
+            .append("`")
+            .append(i == nodeNames.size() - 1 ? "" : ".");
+      } else {
+        builder.append(nodeNames.get(i).getText());
+      }
+    }
+    try {
+      return new PartialPath(builder.toString());
+    } catch (final IllegalPathException e) {
+      throw new SemanticException(e);
+    }
   }
 
   @Override

Reply via email to