Commit 80913511 authored by wenmo's avatar wenmo

新血缘分析部分

parent 4d3cdb71
...@@ -96,4 +96,12 @@ public class JobInstanceController { ...@@ -96,4 +96,12 @@ public class JobInstanceController {
public Result refreshJobInfoDetail(@RequestParam Integer id) { public Result refreshJobInfoDetail(@RequestParam Integer id) {
return Result.succeed(taskService.refreshJobInfoDetail(id), "刷新成功"); return Result.succeed(taskService.refreshJobInfoDetail(id), "刷新成功");
} }
/**
* 获取单表的血缘分析
*/
@GetMapping("/getOneTableColumnCA")
public Result getOneTableColumnCA(@RequestParam Integer id) {
return Result.succeed(jobInstanceService.getOneTableColumnCA(id), "刷新成功");
}
} }
package com.dlink.service; package com.dlink.service;
import com.dlink.db.service.ISuperService; import com.dlink.db.service.ISuperService;
import com.dlink.explainer.ca.TableCANode;
import com.dlink.model.JobInfoDetail; import com.dlink.model.JobInfoDetail;
import com.dlink.model.JobInstance; import com.dlink.model.JobInstance;
import com.dlink.model.JobInstanceStatus; import com.dlink.model.JobInstanceStatus;
...@@ -23,4 +24,5 @@ public interface JobInstanceService extends ISuperService<JobInstance> { ...@@ -23,4 +24,5 @@ public interface JobInstanceService extends ISuperService<JobInstance> {
JobInfoDetail getJobInfoDetailInfo(JobInstance jobInstance); JobInfoDetail getJobInfoDetailInfo(JobInstance jobInstance);
List<TableCANode> getOneTableColumnCA(Integer id);
} }
...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.constant.FlinkRestResultConstant; import com.dlink.constant.FlinkRestResultConstant;
import com.dlink.db.service.impl.SuperServiceImpl; import com.dlink.db.service.impl.SuperServiceImpl;
import com.dlink.explainer.ca.CABuilder;
import com.dlink.explainer.ca.TableCANode;
import com.dlink.mapper.JobInstanceMapper; import com.dlink.mapper.JobInstanceMapper;
import com.dlink.model.Cluster; import com.dlink.model.Cluster;
import com.dlink.model.History; import com.dlink.model.History;
...@@ -124,4 +126,9 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper, ...@@ -124,4 +126,9 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper,
return jobInfoDetail; return jobInfoDetail;
} }
@Override
public List<TableCANode> getOneTableColumnCA(Integer id) {
return CABuilder.getOneTableColumnCAByStatement(getJobInfoDetail(id).getHistory().getStatement());
}
} }
package com.dlink.explainer.lineage;
import com.dlink.explainer.ca.ColumnCAResult;
import com.dlink.plus.FlinkSqlPlus;
import java.util.List;
/**
* LineageBuilder
*
* @author wenmo
* @since 2022/3/15 22:58
*/
public class LineageBuilder {
public static LineageResult getLineage(String statement){
FlinkSqlPlus plus = FlinkSqlPlus.build();
List<ColumnCAResult> columnCAResults = plus.explainSqlColumnCA(statement);
for (int j = 0; j < columnCAResults.size(); j++) {
ColumnCAResult result = columnCAResults.get(j);
}
return null;
}
}
package com.dlink.explainer.lineage;
/**
* LineageColumn
*
* @author wenmo
* @since 2022/3/15 22:55
*/
public class LineageColumn {
private String name;
private String title;
public LineageColumn() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
package com.dlink.explainer.lineage;
/**
* LineageRelation
*
* @author wenmo
* @since 2022/3/15 23:00
*/
public class LineageRelation {
private String id;
private String srcTableId;
private String tgtTableId;
private String srcTableColName;
private String tgtTableColName;
public LineageRelation() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSrcTableId() {
return srcTableId;
}
public void setSrcTableId(String srcTableId) {
this.srcTableId = srcTableId;
}
public String getTgtTableId() {
return tgtTableId;
}
public void setTgtTableId(String tgtTableId) {
this.tgtTableId = tgtTableId;
}
public String getSrcTableColName() {
return srcTableColName;
}
public void setSrcTableColName(String srcTableColName) {
this.srcTableColName = srcTableColName;
}
public String getTgtTableColName() {
return tgtTableColName;
}
public void setTgtTableColName(String tgtTableColName) {
this.tgtTableColName = tgtTableColName;
}
}
package com.dlink.explainer.lineage;
import java.util.List;
/**
* LineageResult
*
* @author wenmo
* @since 2022/3/15 22:59
*/
public class LineageResult {
private List<LineageTable> tables;
private List<LineageRelation> relations;
public LineageResult() {
}
public List<LineageTable> getTables() {
return tables;
}
public void setTables(List<LineageTable> tables) {
this.tables = tables;
}
public List<LineageRelation> getRelations() {
return relations;
}
public void setRelations(List<LineageRelation> relations) {
this.relations = relations;
}
}
package com.dlink.explainer.lineage;
import java.util.List;
/**
* LineageTable
*
* @author wenmo
* @since 2022/3/15 22:55
*/
public class LineageTable {
private String id;
private String name;
private List<LineageColumn> columns;
public LineageTable() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<LineageColumn> getColumns() {
return columns;
}
public void setColumns(List<LineageColumn> columns) {
this.columns = columns;
}
}
package com.dlink.core;
import com.dlink.explainer.ca.CABuilder;
import com.dlink.explainer.ca.ColumnCANode;
import com.dlink.explainer.ca.TableCANode;
import com.dlink.explainer.lineage.LineageBuilder;
import com.dlink.explainer.lineage.LineageResult;
import org.junit.Test;
import java.util.List;
/**
* LineageTest
*
* @author wenmo
* @since 2022/3/15 23:08
*/
public class LineageTest {
@Test
public void sumTest() {
String sql = "CREATE TABLE ST (\n" +
" a STRING,\n" +
" b STRING,\n" +
" c STRING\n" +
") WITH (\n" +
" 'connector' = 'datagen',\n" +
" 'rows-per-second' = '1'\n" +
");\n" +
"CREATE TABLE TT (\n" +
" A STRING,\n" +
" B STRING\n" +
") WITH (\n" +
" 'connector' = 'print'\n" +
");\n" +
"insert into TT select a||c A ,b B from ST";
LineageResult result = LineageBuilder.getLineage(sql);
System.out.println("end");
}
}
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
"react-dom": "^17.0.0", "react-dom": "^17.0.0",
"react-helmet-async": "^1.0.4", "react-helmet-async": "^1.0.4",
"react-highlight-words": "^0.17.0", "react-highlight-words": "^0.17.0",
"react-lineage-dag": "^1.0.0",
"react-monaco-editor": "^0.43.0", "react-monaco-editor": "^0.43.0",
"sql-formatter": "^4.0.2", "sql-formatter": "^4.0.2",
"umi": "^3.5.0", "umi": "^3.5.0",
......
import {Tabs, Empty} from 'antd';
import CodeShow from "@/components/Common/CodeShow";
import {LineageTable} from 'react-lineage-dag';
const {TabPane} = Tabs;
const DataMap = (props: any) => {
const {job} = props;
const data = {
tables: [
{
id: '1',
name: 'table-1',
columns: [
{
name: 'id',
title: 'id'
},
{
name: 'age',
title: 'age'
}
]
},
{
id: '2',
name: 'table-2',
columns: [
{
name: 'id',
title: 'id'
},
{
name: 'age',
title: 'age'
}
]
},
{
id: '3',
name: 'table-3',
columns: [
{
name: 'id',
title: 'id'
},
{
name: 'age',
title: 'age'
}
]
}
],
relations: [
{
srcTableId: '1',
tgtTableId: '2',
// srcTableColName: 'id',
// tgtTableColName: 'age'
},
{
srcTableId: '1',
tgtTableId: '3',
// srcTableColName: 'id',
// tgtTableColName: 'age'
}
]
};
return (<>
<Tabs defaultActiveKey="OneCA" size="small" tabPosition="top" style={{
border: "1px solid #f0f0f0"
}}>
<TabPane tab={<span>血缘分析</span>} key="OneCA">
<LineageTable {...data} onEachFrame={() => { }}/>
</TabPane>
</Tabs>
</>)
};
export default DataMap;
...@@ -19,6 +19,7 @@ import JobLifeCycle from "@/components/Common/JobLifeCycle"; ...@@ -19,6 +19,7 @@ import JobLifeCycle from "@/components/Common/JobLifeCycle";
import Exception from "@/pages/DevOps/JobInfo/Exception"; import Exception from "@/pages/DevOps/JobInfo/Exception";
import FlinkSQL from "@/pages/DevOps/JobInfo/FlinkSQL"; import FlinkSQL from "@/pages/DevOps/JobInfo/FlinkSQL";
import Alert from "@/pages/DevOps/JobInfo/Alert"; import Alert from "@/pages/DevOps/JobInfo/Alert";
import DataMap from "@/pages/DevOps/JobInfo/DataMap";
const {Link} = Typography; const {Link} = Typography;
...@@ -261,7 +262,7 @@ const JobInfo = (props: any) => { ...@@ -261,7 +262,7 @@ const JobInfo = (props: any) => {
{tabKey === 'log' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined} {tabKey === 'log' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined}
{tabKey === 'optimize' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined} {tabKey === 'optimize' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined}
{tabKey === 'flinksql' ? <FlinkSQL job={job}/> : undefined} {tabKey === 'flinksql' ? <FlinkSQL job={job}/> : undefined}
{tabKey === 'datamap' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined} {tabKey === 'datamap' ? <DataMap job={job} /> : undefined}
{tabKey === 'olap' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined} {tabKey === 'olap' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined}
{tabKey === 'version' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined} {tabKey === 'version' ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : undefined}
{tabKey === 'alert' ? <Alert job={job} /> : undefined} {tabKey === 'alert' ? <Alert job={job} /> : undefined}
......
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