diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java index bd145e58b9..441a11cd8f 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java @@ -335,6 +335,11 @@ public JobResult debugTask(TaskDTO task) throws Exception { task.setUseResult(true); // Debug mode need execute task.setStatementSet(false); + // mode check + if (GatewayType.get(task.getType()).isDeployCluster()) { + throw new BusException(Status.MODE_IS_NOT_ALLOW_SELECT.getMessage()); + } + // 注解自调用会失效,这里通过获取对象方法绕过此限制 TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class); JobResult jobResult; diff --git a/dinky-common/src/main/java/org/dinky/data/enums/Status.java b/dinky-common/src/main/java/org/dinky/data/enums/Status.java index 2adc547025..4423963f2f 100644 --- a/dinky-common/src/main/java/org/dinky/data/enums/Status.java +++ b/dinky-common/src/main/java/org/dinky/data/enums/Status.java @@ -189,6 +189,8 @@ public enum Status { TASK_IS_PUBLISH_CANNOT_DELETE(12011, "task.is.publish.cannot.delete"), TASK_IS_RUNNING_CANNOT_DELETE(12012, "task.is.running.cannot.delete"), JOB_ALERT_MAX_SEND_COUNT(12013, "job.alert.max.send.count"), + MODE_IS_NOT_ALLOW_SELECT(12014, "mode.is.not.allow.select"), + OPERATE_NOT_SUPPORT_QUERY(12015, "operate.not.support.query"), /** * alert instance @@ -347,7 +349,6 @@ public enum Status { SYS_ENV_SETTINGS_DIFF_MINUTE_MAX_SEND_COUNT(120, "sys.env.settings.diffMinuteMaxSendCount"), SYS_ENV_SETTINGS_DIFF_MINUTE_MAX_SEND_COUNT_NOTE(121, "sys.env.settings.diffMinuteMaxSendCount.note"), - SYS_ENV_SETTINGS_MAX_RETAIN_DAYS(1171, "sys.env.settings.maxRetainDays"), SYS_ENV_SETTINGS_MAX_RETAIN_DAYS_NOTE(1172, "sys.env.settings.maxRetainDays.note"), SYS_ENV_SETTINGS_MAX_RETAIN_COUNT(1173, "sys.env.settings.maxRetainCount"), diff --git a/dinky-common/src/main/resources/i18n/messages_en_US.properties b/dinky-common/src/main/resources/i18n/messages_en_US.properties index ac198935fc..afe031668c 100644 --- a/dinky-common/src/main/resources/i18n/messages_en_US.properties +++ b/dinky-common/src/main/resources/i18n/messages_en_US.properties @@ -275,6 +275,8 @@ gateway.kubernetes.test.failed= failed to test the Flink configuration: task.status.is.not.done=The current job status is not stopped, please stop after operation task.sql.explain.failed=SQL parsing failed, please check the SQL statement task.update.failed=Task Update failed +mode.is.not.allow.select=Application / Pre-Job mode does not allow executing select statements. To perform this operation, please switch to Local, Standalone, or Yarn session modes. +operate.not.support.query=The [Run] button does not support select statements, please switch to the [Query] button. # process process.submit.submitTask= Submit the job diff --git a/dinky-common/src/main/resources/i18n/messages_zh_CN.properties b/dinky-common/src/main/resources/i18n/messages_zh_CN.properties index 3fe5f11cde..89da9de646 100644 --- a/dinky-common/src/main/resources/i18n/messages_zh_CN.properties +++ b/dinky-common/src/main/resources/i18n/messages_zh_CN.properties @@ -275,6 +275,8 @@ gateway.kubernetes.test.failed=测试 Flink 配置失败: task.status.is.not.done=当前作业状态未停止,请停止后操作 task.sql.explain.failed=sql解析失败,请检查 task.update.failed=Task更新失败 +mode.is.not.allow.select=Application / Pre-Job 模式不允许执行 select 语句, 如需执行此操作, 请切换至 Local、Standalone、Yarn session等模式 +operate.not.support.query=[运行] 按钮不支持 select 语句,请切换至 [查询] 按钮 # process process.submit.submitTask=提交作业 diff --git a/dinky-core/src/main/java/org/dinky/job/JobManager.java b/dinky-core/src/main/java/org/dinky/job/JobManager.java index 83dba4a242..d73c224eae 100644 --- a/dinky-core/src/main/java/org/dinky/job/JobManager.java +++ b/dinky-core/src/main/java/org/dinky/job/JobManager.java @@ -28,6 +28,7 @@ import org.dinky.data.annotations.ProcessStep; import org.dinky.data.enums.GatewayType; import org.dinky.data.enums.ProcessStepType; +import org.dinky.data.enums.Status; import org.dinky.data.exception.BusException; import org.dinky.data.model.SystemConfiguration; import org.dinky.data.result.ErrorResult; @@ -108,7 +109,6 @@ public class JobManager { private boolean useStatementSet = false; private boolean useRestAPI = false; private GatewayType runMode = GatewayType.LOCAL; - private JobParam jobParam = null; private String currentSql = ""; private final WeakReference dinkyClassLoader = new WeakReference<>(DinkyClassLoader.build()); @@ -350,8 +350,12 @@ public JobResult executeSql(String statement) throws Exception { success(); } } catch (Exception e) { + String errorMessage = e.getMessage(); + if (errorMessage.contains("Only insert statement is supported now")) { + throw new BusException(Status.OPERATE_NOT_SUPPORT_QUERY.getMessage()); + } String error = StrFormatter.format( - "Exception in executing FlinkSQL:\n{}\n{}", SqlUtil.addLineNumber(currentSql), e.getMessage()); + "Exception in executing FlinkSQL:\n{}\n{}", SqlUtil.addLineNumber(currentSql), errorMessage); job.setEndTime(LocalDateTime.now()); job.setStatus(Job.JobStatus.FAILED); job.setError(error);