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

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


The following commit(s) were added to refs/heads/0392 by this push:
     new a5fb2394267 Avoid 301/305 code about fetch schema failed
a5fb2394267 is described below

commit a5fb239426772f3a6ad0b31149fbab852e10f9c5
Author: JackieTien97 <[email protected]>
AuthorDate: Tue Jun 24 17:42:33 2025 +0800

    Avoid 301/305 code about fetch schema failed
---
 .../metadata/fetcher/TableDeviceSchemaFetcher.java     | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

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 a4d10fdc275..c2e72e3f2ab 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
@@ -147,7 +147,10 @@ public class TableDeviceSchemaFetcher {
           throw AsyncSendPlanNodeHandler.needRetry(e)
               ? new IoTDBRuntimeException(
                   e.getCause(), 
TSStatusCode.SYNC_CONNECTION_ERROR.getStatusCode())
-              : new RuntimeException("Fetch Table Device Schema failed. ", e);
+              : new IoTDBRuntimeException(
+                  String.format("Fetch Table Device Schema failed because %s", 
e.getMessage()),
+                  e.getErrorCode(),
+                  e.isUserException());
         }
         if (!tsBlock.isPresent() || tsBlock.get().isEmpty()) {
           break;
@@ -476,16 +479,16 @@ public class TableDeviceSchemaFetcher {
                   : mppQueryContext.getSession(),
               String.format(
                   "fetch device for query %s : %s",
-                  mppQueryContext.getQueryId(), mppQueryContext.getSql()),
+                  mppQueryContext == null ? "unknown" : 
mppQueryContext.getQueryId(),
+                  mppQueryContext == null ? "unknown" : 
mppQueryContext.getSql()),
               LocalExecutionPlanner.getInstance().metadata,
               mppQueryContext.getTimeOut()
                   - (System.currentTimeMillis() - 
mppQueryContext.getStartTime()),
               false);
 
       if (executionResult.status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-        throw new RuntimeException(
-            new IoTDBException(
-                executionResult.status.getMessage(), 
executionResult.status.getCode()));
+        throw new IoTDBRuntimeException(
+            executionResult.status.getMessage(), 
executionResult.status.getCode());
       }
 
       final List<ColumnHeader> columnHeaderList =
@@ -497,7 +500,10 @@ public class TableDeviceSchemaFetcher {
           tsBlock = coordinator.getQueryExecution(queryId).getBatchResult();
         } catch (final IoTDBException e) {
           t = e;
-          throw new RuntimeException("Fetch Table Device Schema failed. ", e);
+          throw new IoTDBRuntimeException(
+              String.format("Fetch Table Device Schema failed because %s", 
e.getMessage()),
+              e.getErrorCode(),
+              e.isUserException());
         }
         if (!tsBlock.isPresent() || tsBlock.get().isEmpty()) {
           break;

Reply via email to