Unverified Commit 6bd1ed14 authored by 高岩's avatar 高岩 Committed by GitHub

Bug fix fragement (#1323)

* If the global variable is not enabled, cancel the database variable information * If the global variable is not enabled, cancel the database variable information Co-authored-by: steve <woai1998>
parent e8b8e6bd
...@@ -98,10 +98,19 @@ public class Submiter { ...@@ -98,10 +98,19 @@ public class Submiter {
return Arrays.asList(SqlUtil.getStatements(sql)); return Arrays.asList(SqlUtil.getStatements(sql));
} }
public static String getDbSourceSqlStatements(DBConfig dbConfig) { public static String getDbSourceSqlStatements(DBConfig dbConfig, Integer id) {
String sql = "select name,flink_config from dlink_database where enabled = 1"; String sql = "select name,flink_config from dlink_database where enabled = 1";
String sqlCheck = "select fragment from dlink_task where id = " + id;
try { try {
// 首先判断是否开启了全局变量
String fragment = DBUtil.getOneByID(sqlCheck, dbConfig);
if (fragment.equals("1")) {
return DBUtil.getDbSourceSQLStatement(sql, dbConfig); return DBUtil.getDbSourceSQLStatement(sql, dbConfig);
} else {
// 全局变量未开启,返回空字符串
logger.info("任务 {} 未开启全局变量,不进行变量加载。");
return "";
}
} catch (IOException | SQLException e) { } catch (IOException | SQLException e) {
logger.error("{} --> 获取 数据源信息异常,请检查数据库连接,连接信息为:{} ,异常信息为:{}", LocalDateTime.now(), logger.error("{} --> 获取 数据源信息异常,请检查数据库连接,连接信息为:{} ,异常信息为:{}", LocalDateTime.now(),
dbConfig.toString(), e.getMessage(), e); dbConfig.toString(), e.getMessage(), e);
...@@ -122,7 +131,7 @@ public class Submiter { ...@@ -122,7 +131,7 @@ public class Submiter {
sb.append("\n"); sb.append("\n");
} }
// 添加数据源全局变量 // 添加数据源全局变量
sb.append(getDbSourceSqlStatements(dbConfig)); sb.append(getDbSourceSqlStatements(dbConfig, id));
// 添加自定义全局变量信息 // 添加自定义全局变量信息
sb.append(getFlinkSQLStatement(id, dbConfig)); sb.append(getFlinkSQLStatement(id, dbConfig));
List<String> statements = Submiter.getStatements(sb.toString()); List<String> statements = Submiter.getStatements(sb.toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment