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

weihao pushed a commit to branch addQueryDebug
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/addQueryDebug by this push:
     new 4640774700e perfect it
4640774700e is described below

commit 4640774700e40b41d704ce72cb216b83cd8c7563
Author: Weihao Li <[email protected]>
AuthorDate: Fri Feb 6 12:44:24 2026 +0800

    perfect it
    
    Signed-off-by: Weihao Li <[email protected]>
---
 .../it/env/cluster/node/AbstractNodeWrapper.java   |  15 +++
 .../it/query/recent/IoTDBDebugQueryIT.java         | 104 +++++++++++++++++++++
 .../iotdb/db/queryengine/plan/Coordinator.java     |  53 +++++++++++
 3 files changed, 172 insertions(+)

diff --git 
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
 
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
index cbcf4ca3fd5..14ef8b36ef7 100644
--- 
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
+++ 
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/AbstractNodeWrapper.java
@@ -57,6 +57,7 @@ import java.nio.file.NoSuchFileException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -834,4 +835,18 @@ public abstract class AbstractNodeWrapper implements 
BaseNodeWrapper {
   public int[] getPortList() {
     return portList;
   }
+
+  public void clearLogContent() throws IOException {
+    Files.newOutputStream(Paths.get(getLogPath()), 
StandardOpenOption.TRUNCATE_EXISTING).close();
+  }
+
+  public boolean logContains(String content) throws IOException {
+    List<String> lines = Files.readAllLines(Paths.get(getLogPath()), 
StandardCharsets.UTF_8);
+    for (String line : lines) {
+      if (line.contains(content)) {
+        return true;
+      }
+    }
+    return false;
+  }
 }
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java
new file mode 100644
index 00000000000..35993fa6a08
--- /dev/null
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.relational.it.query.recent;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData;
+import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
+import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({TableLocalStandaloneIT.class})
+public class IoTDBDebugQueryIT {
+  private static final String DATABASE_NAME = "test_db";
+  private static final String[] createTableSqls =
+      new String[] {
+        "CREATE DATABASE " + DATABASE_NAME,
+        "USE " + DATABASE_NAME,
+        "create table table1(device string tag, value int32 field)",
+        "insert into table1(time,device,value) values(2020-01-01 
00:00:01.000,'d1',1)",
+        "FLUSH",
+      };
+  private static final String[] createTreeSqls =
+      new String[] {
+        "create timeseries root.test.departments.department_id TEXT",
+        "create timeseries root.test.departments.dep_name TEXT",
+        "insert into root.test.departments(time, department_id, dep_name) 
values(1, 'D001', '研发部')",
+        "FLUSH",
+      };
+  private static DataNodeWrapper dataNodeWrapper;
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvFactory.getEnv().initClusterEnvironment();
+    dataNodeWrapper = EnvFactory.getEnv().getDataNodeWrapperList().get(0);
+    prepareTableData(createTableSqls);
+    prepareData(createTreeSqls);
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void treeTest() throws IOException {
+    // clear log content to reduce lines spanned in logContains check
+    dataNodeWrapper.clearLogContent();
+
+    String[] expectedHeader = new String[] {"time", "device", "value"};
+    String[] retArray = new String[] {"2020-01-01T00:00:01.000Z,d1,1,"};
+    tableResultSetEqualTest(
+        "debug select time,device,value from table1", expectedHeader, 
retArray, DATABASE_NAME);
+
+    dataNodeWrapper.logContains("Cache miss: table1.d1");
+  }
+
+  @Test
+  public void tableTest() throws IOException {
+    // clear log content to reduce lines spanned in logContains check
+    dataNodeWrapper.clearLogContent();
+
+    String[] expectedHeader =
+        new String[] {
+          "Time", "root.test.departments.department_id", 
"root.test.departments.dep_name"
+        };
+    String[] retArray = new String[] {"1,D001,研发部,"};
+    resultSetEqualTest(
+        "debug select department_id, dep_name from root.test.departments",
+        expectedHeader,
+        retArray);
+
+    dataNodeWrapper.logContains("Cache miss: root.test.departments");
+  }
+}
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
index ed251f91e7e..d8ed2a320ac 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
@@ -306,6 +306,9 @@ public class Coordinator {
       if (LOGGER.isDebugEnabled() && sql != null && !sql.isEmpty()) {
         LOGGER.debug("[QueryStart] sql: {}", sql);
       }
+      if (userQuery) {
+        System.out.println("--------------" + debug);
+      }
       queryContext =
           new MPPQueryContext(
               sql,
@@ -488,6 +491,8 @@ public class Coordinator {
                 startTime)));
   }
 
+  /** For compatibility of MQTT and REST, this method should never be called. 
*/
+  @Deprecated
   public ExecutionResult executeForTableModel(
       Statement statement,
       SqlParser sqlParser,
@@ -514,6 +519,54 @@ public class Coordinator {
                 startTime)));
   }
 
+  /** For compatibility of MQTT and REST, this method should never be called. 
*/
+  @Deprecated
+  public ExecutionResult executeForTreeModel(
+      Statement statement,
+      long queryId,
+      SessionInfo sessionInfo,
+      String s,
+      IPartitionFetcher partitionFetcher,
+      ISchemaFetcher schemaFetcher,
+      long queryTimeoutThreshold,
+      boolean isUserQuery) {
+    return executeForTreeModel(
+        statement,
+        queryId,
+        sessionInfo,
+        s,
+        partitionFetcher,
+        schemaFetcher,
+        queryTimeoutThreshold,
+        isUserQuery,
+        false);
+  }
+
+  /** For compatibility of MQTT and REST, this method should never be called. 
*/
+  @Deprecated
+  public ExecutionResult executeForTableModel(
+      org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Statement 
statement,
+      SqlParser sqlParser,
+      IClientSession currSession,
+      Long queryId,
+      SessionInfo sessionInfo,
+      String sql,
+      Metadata metadata,
+      long queryTimeoutThreshold,
+      boolean isUserQuery) {
+    return executeForTableModel(
+        statement,
+        sqlParser,
+        currSession,
+        queryId,
+        sessionInfo,
+        sql,
+        metadata,
+        queryTimeoutThreshold,
+        isUserQuery,
+        false);
+  }
+
   private IQueryExecution createQueryExecutionForTableModel(
       Statement statement,
       SqlParser sqlParser,

Reply via email to