Unverified Commit 9a3cb09e authored by Licho's avatar Licho Committed by GitHub

feat: add explain error line for some (#2657)

* feat: add explain error line for some Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> * Spotless Apply --------- Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> Co-authored-by: 's avatarleechor <leechor@users.noreply.github.com>
parent 4a932b74
...@@ -59,6 +59,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -59,6 +59,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -209,7 +210,10 @@ public class Explainer { ...@@ -209,7 +210,10 @@ public class Explainer {
} }
executor.executeSql(item.getValue()); executor.executeSql(item.getValue());
} catch (Exception e) { } catch (Exception e) {
String error = LogUtil.getError(e); String error = StrFormatter.format(
"Exception in executing FlinkSQL:\n{}\n{}",
SqlUtil.addLineNumber(item.getValue()),
e.getMessage());
record.setError(error); record.setError(error);
record.setExplainTrue(false); record.setExplainTrue(false);
record.setExplainTime(LocalDateTime.now()); record.setExplainTime(LocalDateTime.now());
...@@ -264,7 +268,10 @@ public class Explainer { ...@@ -264,7 +268,10 @@ public class Explainer {
record.setParseTrue(true); record.setParseTrue(true);
record.setExplainTrue(true); record.setExplainTrue(true);
} catch (Exception e) { } catch (Exception e) {
String error = LogUtil.getError(e); String error = StrFormatter.format(
"Exception in executing FlinkSQL:\n{}\n{}",
SqlUtil.addLineNumber(item.getValue()),
e.getMessage());
record.setError(error); record.setError(error);
record.setParseTrue(false); record.setParseTrue(false);
record.setExplainTrue(false); record.setExplainTrue(false);
...@@ -292,7 +299,10 @@ public class Explainer { ...@@ -292,7 +299,10 @@ public class Explainer {
record.setType("DATASTREAM"); record.setType("DATASTREAM");
record.setParseTrue(true); record.setParseTrue(true);
} catch (Exception e) { } catch (Exception e) {
String error = LogUtil.getError(e); String error = StrFormatter.format(
"Exception in executing FlinkSQL:\n{}\n{}",
SqlUtil.addLineNumber(item.getValue()),
e.getMessage());
record.setError(error); record.setError(error);
record.setExplainTrue(false); record.setExplainTrue(false);
record.setExplainTime(LocalDateTime.now()); record.setExplainTime(LocalDateTime.now());
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
import CodeShow from '@/components/CustomEditor/CodeShow'; import CodeShow from '@/components/CustomEditor/CodeShow';
import { SseData } from '@/models/Sse'; import { SseData } from '@/models/Sse';
import {DataStudioTabsItemType, StateType, VIEW} from '@/pages/DataStudio/model'; import { DataStudioTabsItemType, StateType, VIEW } from '@/pages/DataStudio/model';
import { SSE_TOPIC } from '@/pages/DevOps/constants'; import { SSE_TOPIC } from '@/pages/DevOps/constants';
import { API_CONSTANTS } from '@/services/endpoints'; import { API_CONSTANTS } from '@/services/endpoints';
import { parseMilliSecondStr } from '@/utils/function'; import { parseMilliSecondStr } from '@/utils/function';
......
...@@ -17,21 +17,21 @@ ...@@ -17,21 +17,21 @@
* *
*/ */
import {getFooterValue, isDataStudioTabsItemType} from '@/pages/DataStudio/function'; import { getFooterValue, isDataStudioTabsItemType } from '@/pages/DataStudio/function';
import {getTaskData} from '@/pages/DataStudio/LeftContainer/Project/service'; import { getTaskData } from '@/pages/DataStudio/LeftContainer/Project/service';
import { import {
getFlinkConfigs, getFlinkConfigs,
querySuggessionData querySuggessionData
} from '@/pages/DataStudio/RightContainer/JobConfig/service'; } from '@/pages/DataStudio/RightContainer/JobConfig/service';
import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data'; import { QueryParams } from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
import {SuggestionInfo} from '@/types/Public/data'; import { SuggestionInfo } from '@/types/Public/data';
import {Cluster, DataSources} from '@/types/RegCenter/data'; import { Cluster, DataSources } from '@/types/RegCenter/data';
import {l} from '@/utils/intl'; import { l } from '@/utils/intl';
import {createModelTypes} from '@/utils/modelUtils'; import { createModelTypes } from '@/utils/modelUtils';
import {Effect, Reducer} from '@@/plugin-dva/types'; import { Effect, Reducer } from '@@/plugin-dva/types';
import {Monaco} from '@monaco-editor/react'; import { Monaco } from '@monaco-editor/react';
import {DefaultOptionType} from 'antd/es/select'; import { DefaultOptionType } from 'antd/es/select';
import {editor} from 'monaco-editor'; import { editor } from 'monaco-editor';
import React from 'react'; import React from 'react';
import ICodeEditor = editor.ICodeEditor; import ICodeEditor = editor.ICodeEditor;
...@@ -401,21 +401,21 @@ const Model: ModelType = { ...@@ -401,21 +401,21 @@ const Model: ModelType = {
suggestions: [] suggestions: []
}, },
effects: { effects: {
* queryProject({payload}, {call, put}) { *queryProject({ payload }, { call, put }) {
const response: [] = yield call(getTaskData, payload); const response: [] = yield call(getTaskData, payload);
yield put({ yield put({
type: 'saveProject', type: 'saveProject',
payload: response payload: response
}); });
}, },
* queryFlinkConfigOptions({payload}, {call, put}) { *queryFlinkConfigOptions({ payload }, { call, put }) {
const response: [] = yield call(getFlinkConfigs, payload); const response: [] = yield call(getFlinkConfigs, payload);
yield put({ yield put({
type: 'saveFlinkConfigOptions', type: 'saveFlinkConfigOptions',
payload: response payload: response
}); });
}, },
* querySuggestions({payload}, {call, put}) { *querySuggestions({ payload }, { call, put }) {
const response: SuggestionInfo[] = yield call(querySuggessionData, payload); const response: SuggestionInfo[] = yield call(querySuggessionData, payload);
yield put({ yield put({
type: 'updateSuggestions', type: 'updateSuggestions',
...@@ -427,7 +427,7 @@ const Model: ModelType = { ...@@ -427,7 +427,7 @@ const Model: ModelType = {
/** /**
* 更新工具栏高度 * 更新工具栏高度
*/ */
updateToolContentHeight(state, {payload}) { updateToolContentHeight(state, { payload }) {
if (payload != state.toolContentHeight) { if (payload != state.toolContentHeight) {
return { return {
...state, ...state,
...@@ -439,7 +439,7 @@ const Model: ModelType = { ...@@ -439,7 +439,7 @@ const Model: ModelType = {
/** /**
* 更新中间内容高度 * 更新中间内容高度
*/ */
updateCenterContentHeight(state, {payload}) { updateCenterContentHeight(state, { payload }) {
if (payload != state.centerContentHeight) { if (payload != state.centerContentHeight) {
return { return {
...state, ...state,
...@@ -451,7 +451,7 @@ const Model: ModelType = { ...@@ -451,7 +451,7 @@ const Model: ModelType = {
/** /**
* 更新左侧选中key * 更新左侧选中key
*/ */
updateSelectLeftKey(state, {payload}) { updateSelectLeftKey(state, { payload }) {
return { return {
...state, ...state,
leftContainer: { leftContainer: {
...@@ -464,7 +464,7 @@ const Model: ModelType = { ...@@ -464,7 +464,7 @@ const Model: ModelType = {
/** /**
* 更新左侧宽度 * 更新左侧宽度
*/ */
updateLeftWidth(state, {payload}) { updateLeftWidth(state, { payload }) {
return { return {
...state, ...state,
leftContainer: { leftContainer: {
...@@ -476,7 +476,7 @@ const Model: ModelType = { ...@@ -476,7 +476,7 @@ const Model: ModelType = {
/** /**
* 更新右侧选中key * 更新右侧选中key
*/ */
updateSelectRightKey(state, {payload}) { updateSelectRightKey(state, { payload }) {
return { return {
...state, ...state,
rightContainer: { rightContainer: {
...@@ -488,7 +488,7 @@ const Model: ModelType = { ...@@ -488,7 +488,7 @@ const Model: ModelType = {
/** /**
* 更新右侧选中key * 更新右侧选中key
*/ */
updateRightWidth(state, {payload}) { updateRightWidth(state, { payload }) {
return { return {
...state, ...state,
rightContainer: { rightContainer: {
...@@ -500,7 +500,7 @@ const Model: ModelType = { ...@@ -500,7 +500,7 @@ const Model: ModelType = {
/** /**
* 更新底部选中key * 更新底部选中key
*/ */
updateSelectBottomKey(state, {payload}) { updateSelectBottomKey(state, { payload }) {
let centerContentHeight = 0; let centerContentHeight = 0;
let toolContentHeight = 0; let toolContentHeight = 0;
if (payload === '') { if (payload === '') {
...@@ -524,7 +524,7 @@ const Model: ModelType = { ...@@ -524,7 +524,7 @@ const Model: ModelType = {
} }
}; };
}, },
updateSelectBottomSubKey(state, {payload}) { updateSelectBottomSubKey(state, { payload }) {
return { return {
...state, ...state,
bottomContainer: { bottomContainer: {
...@@ -539,7 +539,7 @@ const Model: ModelType = { ...@@ -539,7 +539,7 @@ const Model: ModelType = {
/** /**
* 更新底部高度 * 更新底部高度
*/ */
updateBottomHeight(state, {payload}) { updateBottomHeight(state, { payload }) {
if (payload != state.bottomContainer.height) { if (payload != state.bottomContainer.height) {
return { return {
...state, ...state,
...@@ -554,36 +554,36 @@ const Model: ModelType = { ...@@ -554,36 +554,36 @@ const Model: ModelType = {
/** /**
* 更新数据库列表 * 更新数据库列表
*/ */
saveDataBase(state, {payload}) { saveDataBase(state, { payload }) {
return { return {
...state, ...state,
database: {...state.database, dbData: payload} database: { ...state.database, dbData: payload }
}; };
}, },
saveProject(state, {payload}) { saveProject(state, { payload }) {
return { return {
...state, ...state,
project: {...state.project, data: payload} project: { ...state.project, data: payload }
}; };
}, },
updateProjectExpandKey(state, {payload}) { updateProjectExpandKey(state, { payload }) {
return { return {
...state, ...state,
project: {...state.project, expandKeys: payload} project: { ...state.project, expandKeys: payload }
}; };
}, },
updateProjectSelectKey(state, {payload}) { updateProjectSelectKey(state, { payload }) {
return { return {
...state, ...state,
project: {...state.project, selectKey: payload} project: { ...state.project, selectKey: payload }
}; };
}, },
/** /**
* flink config options * flink config options
*/ */
saveFlinkConfigOptions(state, {payload}) { saveFlinkConfigOptions(state, { payload }) {
return { return {
...state, ...state,
flinkConfigOptions: payload flinkConfigOptions: payload
...@@ -592,7 +592,7 @@ const Model: ModelType = { ...@@ -592,7 +592,7 @@ const Model: ModelType = {
/** /**
* 更新tabs activeKey * 更新tabs activeKey
*/ */
updateTabsActiveKey(state, {payload}) { updateTabsActiveKey(state, { payload }) {
const itemTypes = state.tabs.panes.filter((x) => x.key === payload); const itemTypes = state.tabs.panes.filter((x) => x.key === payload);
if (itemTypes.length === 1) { if (itemTypes.length === 1) {
let footerValue: object = getFooterValue(state.tabs.panes, payload); let footerValue: object = getFooterValue(state.tabs.panes, payload);
...@@ -627,10 +627,10 @@ const Model: ModelType = { ...@@ -627,10 +627,10 @@ const Model: ModelType = {
/** /**
* 移除标签 * 移除标签
*/ */
removeTag(state, {payload}) { removeTag(state, { payload }) {
const needRemoveKey = payload; const needRemoveKey = payload;
const { const {
tabs: {panes, activeKey} tabs: { panes, activeKey }
} = state; } = state;
const index = panes.findIndex((item, index) => { const index = panes.findIndex((item, index) => {
...@@ -658,17 +658,22 @@ const Model: ModelType = { ...@@ -658,17 +658,22 @@ const Model: ModelType = {
/** /**
* 关闭tab * 关闭tab
*/ */
closeTab(state, {payload}) { closeTab(state, { payload }) {
const needCloseKey = (payload as TargetKey).toString(); const needCloseKey = (payload as TargetKey).toString();
const { const {
tabs: {panes, activeKey} tabs: { panes, activeKey }
} = state; } = state;
// close self // close self
if (needCloseKey === activeKey) { if (needCloseKey === activeKey) {
for (const [index, pane] of panes.entries()) { for (const [index, pane] of panes.entries()) {
if (pane.key === needCloseKey) { if (pane.key === needCloseKey) {
const nextPane = panes[(index + 1) % panes.length]; const nextPane = panes[(index + 1) % panes.length];
const height = document.documentElement.clientHeight - VIEW.headerHeight - VIEW.headerNavHeight - VIEW.footerHeight - VIEW.otherHeight; const height =
document.documentElement.clientHeight -
VIEW.headerHeight -
VIEW.headerNavHeight -
VIEW.footerHeight -
VIEW.otherHeight;
return { return {
...state, ...state,
tabs: { tabs: {
...@@ -683,8 +688,9 @@ const Model: ModelType = { ...@@ -683,8 +688,9 @@ const Model: ModelType = {
...state.footContainer, ...state.footContainer,
...getFooterValue(panes, nextPane.key) ...getFooterValue(panes, nextPane.key)
}, },
toolContentHeight: panes.length < 2 ? height - VIEW.leftMargin : state.toolContentHeight, toolContentHeight:
centerContentHeight: panes.length < 2 ? height : state.toolContentHeight, panes.length < 2 ? height - VIEW.leftMargin : state.toolContentHeight,
centerContentHeight: panes.length < 2 ? height : state.toolContentHeight
}; };
} }
} }
...@@ -708,7 +714,7 @@ const Model: ModelType = { ...@@ -708,7 +714,7 @@ const Model: ModelType = {
/** /**
* 添加tab 如果存在则不添加 * 添加tab 如果存在则不添加
*/ */
addTab(state, {payload}) { addTab(state, { payload }) {
const node = payload as TabsItemType; const node = payload as TabsItemType;
for (const item of state.tabs.panes) { for (const item of state.tabs.panes) {
if (item.id === node.id) { if (item.id === node.id) {
...@@ -763,7 +769,7 @@ const Model: ModelType = { ...@@ -763,7 +769,7 @@ const Model: ModelType = {
/** /**
* 关闭其他tab * 关闭其他tab
*/ */
closeOtherTabs(state, {payload}) { closeOtherTabs(state, { payload }) {
// 从 pans 中找到需要关闭的 tab // 从 pans 中找到需要关闭的 tab
const tabsItem = state.tabs.panes.find((pane) => pane.key === payload.key); const tabsItem = state.tabs.panes.find((pane) => pane.key === payload.key);
return { return {
...@@ -779,10 +785,10 @@ const Model: ModelType = { ...@@ -779,10 +785,10 @@ const Model: ModelType = {
/** /**
* 更新选中数据库id * 更新选中数据库id
*/ */
updateSelectDatabaseId(state, {payload}) { updateSelectDatabaseId(state, { payload }) {
return { return {
...state, ...state,
database: {...state.database, selectDatabaseId: payload} database: { ...state.database, selectDatabaseId: payload }
}; };
}, },
...@@ -792,22 +798,22 @@ const Model: ModelType = { ...@@ -792,22 +798,22 @@ const Model: ModelType = {
* @param payload * @param payload
* @returns {any} * @returns {any}
*/ */
updateDatabaseExpandKey(state, {payload}) { updateDatabaseExpandKey(state, { payload }) {
return { return {
...state, ...state,
database: {...state.database, expandKeys: payload} database: { ...state.database, expandKeys: payload }
}; };
}, },
/** /**
* 更新数据库选中key * 更新数据库选中key
*/ */
updateDatabaseSelectKey(state, {payload}) { updateDatabaseSelectKey(state, { payload }) {
return { return {
...state, ...state,
database: {...state.database, selectKeys: payload} database: { ...state.database, selectKeys: payload }
}; };
}, },
updateBottomConsole(state, {payload}) { updateBottomConsole(state, { payload }) {
return { return {
...state, ...state,
bottomContainerContent: { bottomContainerContent: {
...@@ -816,37 +822,37 @@ const Model: ModelType = { ...@@ -816,37 +822,37 @@ const Model: ModelType = {
} }
}; };
}, },
saveSession(state, {payload}) { saveSession(state, { payload }) {
return { return {
...state, ...state,
sessionCluster: payload sessionCluster: payload
}; };
}, },
saveEnv(state, {payload}) { saveEnv(state, { payload }) {
return { return {
...state, ...state,
env: payload env: payload
}; };
}, },
saveTabs(state, {payload}) { saveTabs(state, { payload }) {
return { return {
...state, ...state,
tabs: payload tabs: payload
}; };
}, },
saveClusterConfiguration(state, {payload}) { saveClusterConfiguration(state, { payload }) {
return { return {
...state, ...state,
clusterConfiguration: payload clusterConfiguration: payload
}; };
}, },
saveFooterValue(state, {payload}) { saveFooterValue(state, { payload }) {
return { return {
...state, ...state,
footContainer: payload footContainer: payload
}; };
}, },
updateJobRunningMsg(state, {payload}) { updateJobRunningMsg(state, { payload }) {
return { return {
...state, ...state,
footContainer: { footContainer: {
...@@ -855,7 +861,7 @@ const Model: ModelType = { ...@@ -855,7 +861,7 @@ const Model: ModelType = {
} }
}; };
}, },
updateSuggestions(state, {payload}) { updateSuggestions(state, { payload }) {
return { return {
...state, ...state,
suggestions: payload suggestions: payload
......
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