Commit f9cfbc03 authored by godkaikai's avatar godkaikai

片段机制bug解决

parent a052db28
...@@ -49,6 +49,7 @@ Dinky(原 Dlink): ...@@ -49,6 +49,7 @@ Dinky(原 Dlink):
| | | 新增 选中片段执行 | 0.4.0 | | | | 新增 选中片段执行 | 0.4.0 |
| | | 新增 布局拖拽 | 0.4.0 | | | | 新增 布局拖拽 | 0.4.0 |
| | | 新增 SQL导出 | 0.5.0 | | | | 新增 SQL导出 | 0.5.0 |
| | | 新增 快捷键保存、校验、美化 | 0.5.0 |
| | | 支持 local 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 local 模式下 FlinkSQL 提交 | 0.4.0 |
| | | 支持 standalone 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 standalone 模式下 FlinkSQL 提交 | 0.4.0 |
| | | 支持 yarn session 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 yarn session 模式下 FlinkSQL 提交 | 0.4.0 |
......
...@@ -9,6 +9,7 @@ import com.dlink.explainer.trans.TransGenerator; ...@@ -9,6 +9,7 @@ import com.dlink.explainer.trans.TransGenerator;
import com.dlink.interceptor.FlinkInterceptor; import com.dlink.interceptor.FlinkInterceptor;
import com.dlink.job.JobParam; import com.dlink.job.JobParam;
import com.dlink.job.StatementParam; import com.dlink.job.StatementParam;
import com.dlink.model.SystemConfiguration;
import com.dlink.parser.SqlType; import com.dlink.parser.SqlType;
import com.dlink.result.ExplainResult; import com.dlink.result.ExplainResult;
import com.dlink.result.SqlExplainResult; import com.dlink.result.SqlExplainResult;
...@@ -162,7 +163,7 @@ public class Explainer { ...@@ -162,7 +163,7 @@ public class Explainer {
} }
} }
if (inserts.size() > 0) { if (inserts.size() > 0) {
String sqlSet = String.join(FlinkSQLConstant.SEPARATOR, inserts); String sqlSet = String.join(";\r\n ", inserts);
try { try {
record.setExplain(executor.explainStatementSet(inserts)); record.setExplain(executor.explainStatementSet(inserts));
record.setParseTrue(true); record.setParseTrue(true);
......
...@@ -19,4 +19,8 @@ public interface FlinkSQLConstant { ...@@ -19,4 +19,8 @@ public interface FlinkSQLConstant {
* DML 类型 * DML 类型
*/ */
String DML = "DML"; String DML = "DML";
/**
* 片段 Fragments 标识
*/
String FRAGMENTS = ":=";
} }
package com.dlink.executor; package com.dlink.executor;
import com.dlink.assertion.Asserts;
import com.dlink.constant.FlinkSQLConstant;
import com.dlink.model.SystemConfiguration;
import org.apache.flink.table.api.DataTypes; import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.ExpressionParserException; import org.apache.flink.table.api.ExpressionParserException;
import org.apache.flink.table.api.Table; import org.apache.flink.table.api.Table;
...@@ -148,23 +151,24 @@ public final class SqlManager { ...@@ -148,23 +151,24 @@ public final class SqlManager {
* @throws ExpressionParserException if the name of the variable under the given sql failed. * @throws ExpressionParserException if the name of the variable under the given sql failed.
*/ */
public String parseVariable(String statement) { public String parseVariable(String statement) {
if (statement == null || "".equals(statement)) { if (Asserts.isNullString(statement)) {
return statement; return statement;
} }
String[] strs = statement.split(";"); String[] strs = statement.split(SystemConfiguration.getInstances().getSqlSeparator());
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < strs.length; i++) { for (int i = 0; i < strs.length; i++) {
String str = strs[i].trim(); String str = strs[i];
if (str.length() == 0) { if (str.trim().length() == 0) {
continue; continue;
} }
if (str.contains(":=")) { str = strs[i];
String[] strs2 = str.split(":="); if (str.contains(FlinkSQLConstant.FRAGMENTS)) {
String[] strs2 = str.split(FlinkSQLConstant.FRAGMENTS);
if (strs2.length >= 2) { if (strs2.length >= 2) {
if (strs2[0].length() == 0) { if (strs2[0].length() == 0) {
throw new ExpressionParserException("Illegal variable name."); throw new ExpressionParserException("Illegal variable name.");
} }
String valueString = str.substring(str.indexOf(":=") + 2); String valueString = str.substring(str.indexOf(FlinkSQLConstant.FRAGMENTS) + 2);
this.registerSqlFragment(strs2[0], replaceVariable(valueString)); this.registerSqlFragment(strs2[0], replaceVariable(valueString));
} else { } else {
throw new ExpressionParserException("Illegal variable definition."); throw new ExpressionParserException("Illegal variable definition.");
......
...@@ -530,7 +530,7 @@ export default (): React.ReactNode => { ...@@ -530,7 +530,7 @@ export default (): React.ReactNode => {
<Link>修复 set 语法在1.11和1.12的兼容问题</Link> <Link>修复 set 语法在1.11和1.12的兼容问题</Link>
</li> </li>
<li> <li>
<Link>升级各版本 Flink 依赖至最新版本以解决核弹问题</Link> <Link>升级 各版本 Flink 依赖至最新版本以解决核弹问题</Link>
</li> </li>
<li> <li>
<Link>新增 Yarn 的 Kerboros 验证</Link> <Link>新增 Yarn 的 Kerboros 验证</Link>
...@@ -539,10 +539,13 @@ export default (): React.ReactNode => { ...@@ -539,10 +539,13 @@ export default (): React.ReactNode => {
<Link>新增 ChangLog 和 Table 的查询及自动停止实现</Link> <Link>新增 ChangLog 和 Table 的查询及自动停止实现</Link>
</li> </li>
<li> <li>
<Link>修改项目名为 Dinky 以及图标</Link> <Link>修改 项目名为 Dinky 以及图标</Link>
</li> </li>
<li> <li>
<Link>优化血缘分析图</Link> <Link>优化 血缘分析图</Link>
</li>
<li>
<Link>新增 快捷键保存、校验、美化</Link>
</li> </li>
</ul> </ul>
</Paragraph> </Paragraph>
......
...@@ -87,6 +87,7 @@ Dinky 通过已注册的集群配置来获取对应的 YarnClient 实例。对 ...@@ -87,6 +87,7 @@ Dinky 通过已注册的集群配置来获取对应的 YarnClient 实例。对
| | | 新增 选中片段执行 | 0.4.0 | | | | 新增 选中片段执行 | 0.4.0 |
| | | 新增 布局拖拽 | 0.4.0 | | | | 新增 布局拖拽 | 0.4.0 |
| | | 新增 SQL导出 | 0.5.0 | | | | 新增 SQL导出 | 0.5.0 |
| | | 新增 快捷键保存、校验、美化 | 0.5.0 |
| | | 支持 local 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 local 模式下 FlinkSQL 提交 | 0.4.0 |
| | | 支持 standalone 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 standalone 模式下 FlinkSQL 提交 | 0.4.0 |
| | | 支持 yarn session 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 yarn session 模式下 FlinkSQL 提交 | 0.4.0 |
......
...@@ -87,6 +87,7 @@ Dinky 通过已注册的集群配置来获取对应的 YarnClient 实例。对 ...@@ -87,6 +87,7 @@ Dinky 通过已注册的集群配置来获取对应的 YarnClient 实例。对
| | | 新增 选中片段执行 | 0.4.0 | | | | 新增 选中片段执行 | 0.4.0 |
| | | 新增 布局拖拽 | 0.4.0 | | | | 新增 布局拖拽 | 0.4.0 |
| | | 新增 SQL导出 | 0.5.0 | | | | 新增 SQL导出 | 0.5.0 |
| | | 新增 快捷键保存、校验、美化 | 0.5.0 |
| | | 支持 local 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 local 模式下 FlinkSQL 提交 | 0.4.0 |
| | | 支持 standalone 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 standalone 模式下 FlinkSQL 提交 | 0.4.0 |
| | | 支持 yarn session 模式下 FlinkSQL 提交 | 0.4.0 | | | | 支持 yarn session 模式下 FlinkSQL 提交 | 0.4.0 |
......
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