From a2b9e5033b190e3d4f4cbe5cb3dbbccec08fbf9b Mon Sep 17 00:00:00 2001
From: aiwenmo <32723967+aiwenmo@users.noreply.github.com>
Date: Sun, 4 Sep 2022 23:19:49 +0800
Subject: [PATCH] [Optimization-881][datastudio] Optimizate FlinkSql explain
exception message (#993)
Co-authored-by: wenmo <32723967+wenmo@users.noreply.github.com>
---
.../StudioConsole/StudioExplain/index.tsx | 39 +++++++------------
.../src/pages/DataStudio/SqlExport/index.tsx | 8 ++--
2 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/dlink-web/src/components/Studio/StudioConsole/StudioExplain/index.tsx b/dlink-web/src/components/Studio/StudioConsole/StudioExplain/index.tsx
index 5556af4fbb..be555c5c91 100644
--- a/dlink-web/src/components/Studio/StudioConsole/StudioExplain/index.tsx
+++ b/dlink-web/src/components/Studio/StudioConsole/StudioExplain/index.tsx
@@ -20,13 +20,14 @@
import {StateType} from "@/pages/DataStudio/model";
import {connect} from "umi";
-import {Button, Tag, Space, Typography, Modal,} from 'antd';
+import {Modal, Space, Tag, Typography,} from 'antd';
import {ConsoleSqlOutlined} from "@ant-design/icons";
import ProList from '@ant-design/pro-list';
import {explainSql} from "@/pages/DataStudio/service";
-import {useRef, useState, useEffect} from "react";
+import {useEffect, useState} from "react";
+import CodeShow from "@/components/Common/CodeShow";
-const {Paragraph,Text} = Typography;
+const {Paragraph, Text} = Typography;
type ExplainItem = {
index: number;
@@ -79,29 +80,24 @@ const StudioExplain = (props: any) => {
setExplainData([]);
const result = explainSql(param);
result.then(res => {
- setExplainData(res.datas);
+ const errorExplainData: [] = [];
let errorCount: number = 0;
for (let i in res.datas) {
if (!res.datas[i].explainTrue || !res.datas[i].parseTrue) {
+ errorExplainData.push(res.datas[i]);
errorCount++;
}
}
if (errorCount == 0) {
+ setExplainData(res.datas);
setResult(全部正确);
} else {
+ setExplainData(errorExplainData);
setResult(存在错误,共计{errorCount}个);
}
})
}, [modalVisible]);
- const renderFooter = () => {
- return (
- <>
-
- >
- );
- };
-
const renderContent = () => {
return (
<>
@@ -144,18 +140,10 @@ const StudioExplain = (props: any) => {
{row.sql}
) : null
}
- {row.explain ?
- (
-
- {row.explain}
-
- ) : null
- }
{row.error ?
(
-
- {row.error}
-
+
) : null
}
>
@@ -189,11 +177,12 @@ const StudioExplain = (props: any) => {
return (
@@ -204,7 +193,7 @@ const StudioExplain = (props: any) => {
);
};
-export default connect(({Studio}: {Studio: StateType}) => ({
+export default connect(({Studio}: { Studio: StateType }) => ({
current: Studio.current,
currentSession: Studio.currentSession,
}))(StudioExplain);
diff --git a/dlink-web/src/pages/DataStudio/SqlExport/index.tsx b/dlink-web/src/pages/DataStudio/SqlExport/index.tsx
index b2f2b75416..41a3ba8e81 100644
--- a/dlink-web/src/pages/DataStudio/SqlExport/index.tsx
+++ b/dlink-web/src/pages/DataStudio/SqlExport/index.tsx
@@ -21,13 +21,14 @@
import {Typography} from 'antd';
import {useEffect, useState} from "react";
import {getData} from "@/components/Common/crud";
+import CodeShow from "@/components/Common/CodeShow";
-const {Text, Paragraph} = Typography;
+const {Paragraph} = Typography;
const SqlExport = (props: any) => {
const {id} = props;
- const [statement, setStatement] = useState();
+ const [statement, setStatement] = useState('');
const refreshStatement = async () => {
const msg = await getData('api/task/exportSql', {id: id});
@@ -42,7 +43,8 @@ const SqlExport = (props: any) => {
- {statement}
+
>)
};