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

commit 134696c0bdfef7d39a7d0af5609e166d22bdbc07
Author: Weihao Li <[email protected]>
AuthorDate: Thu Feb 5 15:51:12 2026 +0800

    FE
    
    Signed-off-by: Weihao Li <[email protected]>
---
 .../legacy/IoTDBLegacyPipeReceiverAgent.java       |  1 +
 .../protocol/legacy/loader/DeletionLoader.java     |  3 +-
 .../protocol/legacy/loader/TsFileLoader.java       |  3 +-
 .../protocol/thrift/IoTDBDataNodeReceiver.java     |  6 ++--
 .../sink/protocol/writeback/WriteBackSink.java     |  3 +-
 .../protocol/thrift/impl/ClientRPCServiceImpl.java | 40 +++++++++++++++-------
 .../impl/DataNodeInternalRPCServiceImpl.java       |  1 +
 .../db/queryengine/common/MPPQueryContext.java     | 10 ++++++
 .../iotdb/db/queryengine/plan/Coordinator.java     | 25 +++++++++++---
 .../load/TreeSchemaAutoCreatorAndVerifier.java     |  1 +
 .../analyze/schema/AutoCreateSchemaExecutor.java   |  1 +
 .../analyze/schema/ClusterSchemaFetchExecutor.java |  1 +
 .../config/executor/ClusterConfigTaskExecutor.java |  1 +
 .../metadata/fetcher/TableDeviceSchemaFetcher.java |  2 ++
 .../fetcher/TableDeviceSchemaValidator.java        |  1 +
 .../plan/relational/planner/CteMaterializer.java   |  1 +
 ...ithUncorrelatedScalarSubqueryReconstructor.java |  3 +-
 .../plan/relational/sql/ast/Statement.java         |  9 +++++
 .../plan/relational/sql/parser/AstBuilder.java     |  4 ++-
 .../load/active/ActiveLoadTsFileLoader.java        |  3 +-
 .../converter/LoadTsFileDataTypeConverter.java     |  1 +
 .../db/relational/grammar/sql/RelationalSql.g4     |  2 +-
 22 files changed, 96 insertions(+), 26 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
index 2c45c42a455..ea7baae7927 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
@@ -165,6 +165,7 @@ public class IoTDBLegacyPipeReceiverAgent {
                   partitionFetcher,
                   schemaFetcher,
                   
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
+                  false,
                   false);
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()
           && result.status.code != 
TSStatusCode.DATABASE_ALREADY_EXISTS.getStatusCode()
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java
index 244ec579206..56875a840ed 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/DeletionLoader.java
@@ -76,7 +76,8 @@ public class DeletionLoader implements ILoader {
                   PARTITION_FETCHER,
                   SCHEMA_FETCHER,
                   
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
-                  false);
+                  false,
+                  statement.isDebug());
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         LOGGER.error("Delete {} error, statement: {}.", deletion, statement);
         LOGGER.error("Delete result status : {}.", result.status);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java
index d3698e97d07..e4a1c079a21 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/loader/TsFileLoader.java
@@ -79,7 +79,8 @@ public class TsFileLoader implements ILoader {
                   PARTITION_FETCHER,
                   SCHEMA_FETCHER,
                   
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
-                  false);
+                  false,
+                  statement.isDebug());
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         LOGGER.error("Load TsFile {} error, statement: {}.", tsFile.getPath(), 
statement);
         LOGGER.error("Load TsFile result status : {}.", result.status);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
index f0796a3b1a0..4670d7eac2a 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
@@ -1050,7 +1050,8 @@ public class IoTDBDataNodeReceiver extends 
IoTDBFileReceiver {
             ClusterPartitionFetcher.getInstance(),
             ClusterSchemaFetcher.getInstance(),
             
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
-            false)
+            false,
+            statement.isDebug())
         .status;
   }
 
@@ -1075,7 +1076,8 @@ public class IoTDBDataNodeReceiver extends 
IoTDBFileReceiver {
                   "",
                   LocalExecutionPlanner.getInstance().metadata,
                   
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
-                  false)
+                  false,
+                  statement.isDebug())
               .status;
 
       // Delete data & Update device attribute is itself idempotent
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/writeback/WriteBackSink.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/writeback/WriteBackSink.java
index c47e00ff92e..9d476c54294 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/writeback/WriteBackSink.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/writeback/WriteBackSink.java
@@ -512,7 +512,8 @@ public class WriteBackSink implements PipeConnector {
               ClusterPartitionFetcher.getInstance(),
               ClusterSchemaFetcher.getInstance(),
               
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
-              false)
+              false,
+              statement.isDebug())
           .status;
     } catch (final IoTDBRuntimeException e) {
       if (e.getErrorCode() == TSStatusCode.NO_PERMISSION.getStatusCode()) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
index 167a1fa914f..45eb4f027a7 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
@@ -343,7 +343,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
                   statement,
                   LocalExecutionPlanner.getInstance().metadata,
                   config.getQueryTimeoutThreshold(),
-                  false);
+                  false,
+                  s.isDebug());
         } else {
           // permission check
           TSStatus status =
@@ -387,7 +388,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
                     partitionFetcher,
                     schemaFetcher,
                     req.getTimeout(),
-                    true);
+                    true,
+                    false);
           }
         }
       } else {
@@ -434,7 +436,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
                   statement,
                   metadata,
                   req.getTimeout(),
-                  true);
+                  true,
+                  false);
         }
       }
 
@@ -583,7 +586,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
               partitionFetcher,
               schemaFetcher,
               req.getTimeout(),
-              true);
+              true,
+              s.isDebug());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         finished = true;
@@ -678,7 +682,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
               partitionFetcher,
               schemaFetcher,
               req.getTimeout(),
-              true);
+              true,
+              s.isDebug());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         finished = true;
@@ -775,7 +780,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
               partitionFetcher,
               schemaFetcher,
               req.getTimeout(),
-              true);
+              true,
+              s.isDebug());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         finished = true;
@@ -1234,7 +1240,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
               partitionFetcher,
               schemaFetcher,
               req.getTimeout(),
-              true);
+              true,
+              s.isDebug());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         finished = true;
@@ -1863,7 +1870,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
                       statement,
                       LocalExecutionPlanner.getInstance().metadata,
                       config.getQueryTimeoutThreshold(),
-                      false);
+                      false,
+                      s.isDebug());
             } else {
               // permission check
               TSStatus status =
@@ -1908,7 +1916,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
                         partitionFetcher,
                         schemaFetcher,
                         config.getQueryTimeoutThreshold(),
-                        false);
+                        false,
+                        s.isDebug());
               }
             }
           } else {
@@ -1954,7 +1963,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
                       statement,
                       metadata,
                       config.getQueryTimeoutThreshold(),
-                      false);
+                      false,
+                      s.isDebug());
             }
           }
 
@@ -2876,7 +2886,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
               partitionFetcher,
               schemaFetcher,
               config.getQueryTimeoutThreshold(),
-              true);
+              true,
+              statement.isDebug());
 
       if (executionResult.status.code != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()
           && executionResult.status.code != 
TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()) {
@@ -3286,6 +3297,7 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
     ExecutionResult result = null;
     final List<? extends Statement> subStatements = 
statement.getSubStatements();
     final int totalSubStatements = subStatements.size();
+    boolean debug = statement.isDebug();
 
     LOGGER.info(
         "Start batch executing {} sub-statement(s) in tree model, queryId: {}",
@@ -3310,7 +3322,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
               partitionFetcher,
               schemaFetcher,
               timeoutMs,
-              userQuery);
+              userQuery,
+              debug);
 
       // Exit early if any sub-statement execution fails
       if (result != null
@@ -3400,7 +3413,8 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
               statementStr,
               metadata,
               timeoutMs,
-              userQuery);
+              userQuery,
+              statement.isDebug());
 
       // Exit early if any sub-statement execution fails
       if (result != null
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
index 46d377be0a1..24a2ff7e9e7 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
@@ -1683,6 +1683,7 @@ public class DataNodeInternalRPCServiceImpl implements 
IDataNodeRPCService.Iface
               partitionFetcher,
               schemaFetcher,
               req.getTimeout(),
+              false,
               false);
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java
index fac3afff8b0..3bd1f28e6ba 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java
@@ -125,6 +125,8 @@ public class MPPQueryContext implements IAuditEntity {
 
   private boolean userQuery = false;
 
+  private boolean debug = false;
+
   private Map<NodeRef<Table>, Query> cteQueries = new HashMap<>();
 
   // Stores the EXPLAIN/EXPLAIN ANALYZE results for Common Table Expressions 
(CTEs)
@@ -503,6 +505,14 @@ public class MPPQueryContext implements IAuditEntity {
     this.userQuery = userQuery;
   }
 
+  public boolean isDebug() {
+    return debug;
+  }
+
+  public void setDebug(boolean debug) {
+    this.debug = debug;
+  }
+
   public boolean isInnerTriggeredQuery() {
     return innerTriggeredQuery;
   }
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 0007f5dc797..af5f208d331 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
@@ -297,6 +297,7 @@ public class Coordinator {
       SessionInfo session,
       String sql,
       boolean userQuery,
+      boolean debug,
       BiFunction<MPPQueryContext, Long, IQueryExecution> 
iQueryExecutionFactory) {
     long startTime = System.currentTimeMillis();
     QueryId globalQueryId = queryIdGenerator.createNextQueryId();
@@ -314,6 +315,7 @@ public class Coordinator {
               DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT,
               DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT);
       queryContext.setUserQuery(userQuery);
+      queryContext.setDebug(debug);
       IQueryExecution execution = iQueryExecutionFactory.apply(queryContext, 
startTime);
       if (execution.isQuery()) {
         queryExecutionMap.put(queryId, execution);
@@ -345,7 +347,15 @@ public class Coordinator {
       IPartitionFetcher partitionFetcher,
       ISchemaFetcher schemaFetcher) {
     return executeForTreeModel(
-        statement, queryId, session, sql, partitionFetcher, schemaFetcher, 
Long.MAX_VALUE, false);
+        statement,
+        queryId,
+        session,
+        sql,
+        partitionFetcher,
+        schemaFetcher,
+        Long.MAX_VALUE,
+        false,
+        false);
   }
 
   public ExecutionResult executeForTreeModel(
@@ -356,12 +366,14 @@ public class Coordinator {
       IPartitionFetcher partitionFetcher,
       ISchemaFetcher schemaFetcher,
       long timeOut,
-      boolean userQuery) {
+      boolean userQuery,
+      boolean debug) {
     return execution(
         queryId,
         session,
         sql,
         userQuery,
+        debug,
         ((queryContext, startTime) ->
             createQueryExecutionForTreeModel(
                 statement,
@@ -425,12 +437,14 @@ public class Coordinator {
       Map<NodeRef<Table>, Query> cteQueries,
       ExplainType explainType,
       long timeOut,
-      boolean userQuery) {
+      boolean userQuery,
+      boolean debug) {
     return execution(
         queryId,
         session,
         sql,
         userQuery,
+        debug,
         ((queryContext, startTime) -> {
           queryContext.setInnerTriggeredQuery(true);
           queryContext.setCteQueries(cteQueries);
@@ -455,12 +469,14 @@ public class Coordinator {
       String sql,
       Metadata metadata,
       long timeOut,
-      boolean userQuery) {
+      boolean userQuery,
+      boolean debug) {
     return execution(
         queryId,
         session,
         sql,
         userQuery,
+        debug,
         ((queryContext, startTime) ->
             createQueryExecutionForTableModel(
                 statement,
@@ -486,6 +502,7 @@ public class Coordinator {
         session,
         sql,
         false,
+        false,
         ((queryContext, startTime) ->
             createQueryExecutionForTableModel(
                 statement,
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/load/TreeSchemaAutoCreatorAndVerifier.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/load/TreeSchemaAutoCreatorAndVerifier.java
index 29d4f1be07b..cf2aedc6c19 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/load/TreeSchemaAutoCreatorAndVerifier.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/load/TreeSchemaAutoCreatorAndVerifier.java
@@ -373,6 +373,7 @@ public class TreeSchemaAutoCreatorAndVerifier {
                 loadTsFileAnalyzer.partitionFetcher,
                 loadTsFileAnalyzer.schemaFetcher,
                 
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
+                false,
                 false);
     if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()
         && result.status.code != 
TSStatusCode.DATABASE_ALREADY_EXISTS.getStatusCode()
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
index ef0ad80306a..2c6ed30cd75 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/AutoCreateSchemaExecutor.java
@@ -93,6 +93,7 @@ class AutoCreateSchemaExecutor {
         schemaFetcher,
         // Never timeout for write statement
         Long.MAX_VALUE,
+        false,
         false);
   }
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
index d6f5fd74fa9..5d6d36d4609 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetchExecutor.java
@@ -98,6 +98,7 @@ class ClusterSchemaFetchExecutor {
         ClusterPartitionFetcher.getInstance(),
         schemaFetcher,
         timeout,
+        false,
         false);
   }
 
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 3627e3f82af..0fa52744816 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
@@ -3039,6 +3039,7 @@ public class ClusterConfigTaskExecutor implements 
IConfigTaskExecutor {
                 ClusterPartitionFetcher.getInstance(),
                 ClusterSchemaFetcher.getInstance(),
                 
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
+                false,
                 false);
     if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
       future.setException(
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
index 049db7dec93..b9b59636b09 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
@@ -135,6 +135,7 @@ public class TableDeviceSchemaFetcher {
               LocalExecutionPlanner.getInstance().metadata,
               // Never timeout for insert
               Long.MAX_VALUE,
+              false,
               false);
 
       if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
@@ -502,6 +503,7 @@ public class TableDeviceSchemaFetcher {
               LocalExecutionPlanner.getInstance().metadata,
               mppQueryContext.getTimeOut()
                   - (System.currentTimeMillis() - 
mppQueryContext.getStartTime()),
+              false,
               false);
 
       if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
index 122d352d332..2331d0e4ffc 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
@@ -242,6 +242,7 @@ public class TableDeviceSchemaValidator {
             LocalExecutionPlanner.getInstance().metadata,
             // Never timeout for write statement
             Long.MAX_VALUE,
+            false,
             false);
     if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
       throw new IoTDBRuntimeException(
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/CteMaterializer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/CteMaterializer.java
index a6ac7a42246..db030146a04 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/CteMaterializer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/CteMaterializer.java
@@ -142,6 +142,7 @@ public class CteMaterializer {
               context.getCteQueries(),
               context.getExplainType(),
               context.getTimeOut(),
+              false,
               false);
       if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return null;
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/PredicateWithUncorrelatedScalarSubqueryReconstructor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/PredicateWithUncorrelatedScalarSubqueryReconstructor.java
index 56c4671fd73..0d023b85ce1 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/PredicateWithUncorrelatedScalarSubqueryReconstructor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/PredicateWithUncorrelatedScalarSubqueryReconstructor.java
@@ -153,7 +153,8 @@ public class 
PredicateWithUncorrelatedScalarSubqueryReconstructor {
               context.getCteQueries(),
               ExplainType.NONE,
               context.getTimeOut(),
-              false);
+              false,
+              q.isDebug());
 
       // This may occur when the subquery cannot be executed in advance (for 
example, with
       // correlated scalar subqueries).
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/Statement.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/Statement.java
index 7ba19b972a2..6548748f7c1 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/Statement.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/Statement.java
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.List;
 
 public abstract class Statement extends Node {
+  private boolean debug;
 
   protected Statement(final @Nullable NodeLocation location) {
     super(location);
@@ -56,4 +57,12 @@ public abstract class Statement extends Node {
   public List<? extends Statement> getSubStatements() {
     return Collections.emptyList();
   }
+
+  public void setDebug(boolean debug) {
+    this.debug = debug;
+  }
+
+  public boolean isDebug() {
+    return debug;
+  }
 }
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 83105468a02..f46b356423d 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
@@ -354,7 +354,9 @@ public class AstBuilder extends 
RelationalSqlBaseVisitor<Node> {
 
   @Override
   public Node visitSingleStatement(RelationalSqlParser.SingleStatementContext 
ctx) {
-    return visit(ctx.statement());
+    Statement statement = (Statement) visit(ctx.statement());
+    statement.setDebug(ctx.DEBUG() != null);
+    return statement;
   }
 
   @Override
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java
index 0e565afd70c..d0be2ead5cb 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java
@@ -257,7 +257,8 @@ public class ActiveLoadTsFileLoader {
               ClusterPartitionFetcher.getInstance(),
               ClusterSchemaFetcher.getInstance(),
               IOTDB_CONFIG.getQueryTimeoutThreshold(),
-              false)
+              false,
+              statement.isDebug())
           .status;
     } finally {
       SESSION_MANAGER.removeCurrSession();
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java
index b45c05a3f30..383ac4a3064 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTsFileDataTypeConverter.java
@@ -178,6 +178,7 @@ public class LoadTsFileDataTypeConverter {
               ClusterPartitionFetcher.getInstance(),
               ClusterSchemaFetcher.getInstance(),
               
IoTDBDescriptor.getInstance().getConfig().getQueryTimeoutThreshold(),
+              false,
               false)
           .status;
     } finally {
diff --git 
a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
 
b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
index 07186fd4222..2982e506ea9 100644
--- 
a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
+++ 
b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
@@ -26,7 +26,7 @@ tokens {
 }
 
 singleStatement
-    : statement EOF
+    : DEBUG? statement EOF
     ;
 
 

Reply via email to