diff --git a/fe/fe-core/src/main/java/com/starrocks/catalog/system/information/TaskRunsSystemTable.java b/fe/fe-core/src/main/java/com/starrocks/catalog/system/information/TaskRunsSystemTable.java index d1e3d8ac802e01..7e35a09c5c9127 100644 --- a/fe/fe-core/src/main/java/com/starrocks/catalog/system/information/TaskRunsSystemTable.java +++ b/fe/fe-core/src/main/java/com/starrocks/catalog/system/information/TaskRunsSystemTable.java @@ -47,6 +47,7 @@ import org.apache.commons.lang3.NotImplementedException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.util.Strings; import org.apache.thrift.meta_data.FieldValueMetaData; import org.apache.thrift.protocol.TType; @@ -210,14 +211,18 @@ public static TGetTaskRunInfoResult query(TGetTasksParams params) { info.setState(status.getState().toString()); info.setCatalog(status.getCatalogName()); info.setDatabase(ClusterNamespace.getNameFromFullName(status.getDbName())); - try { - // NOTE: use task's definition to display task-run's definition here - Task task = taskManager.getTaskWithoutLock(taskName); - if (task != null) { - info.setDefinition(task.getDefinition()); + if (!Strings.isEmpty(status.getDefinition())) { + info.setDefinition(status.getDefinition()); + } else { + try { + // NOTE: use task's definition to display task-run's definition here + Task task = taskManager.getTaskWithoutLock(taskName); + if (task != null) { + info.setDefinition(task.getDefinition()); + } + } catch (Exception e) { + LOG.warn("Get taskName {} definition failed: {}", taskName, e); } - } catch (Exception e) { - LOG.warn("Get taskName {} definition failed: {}", taskName, e); } info.setError_code(status.getErrorCode()); info.setError_message(status.getErrorMessage());