Unverified Commit d89485df authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Optimization-2460][studio] Optimize task preview result (#2461)

parent d72dd525
...@@ -39,13 +39,6 @@ public class DebugDTO { ...@@ -39,13 +39,6 @@ public class DebugDTO {
notes = "The ID of Task which is debugged") notes = "The ID of Task which is debugged")
private Integer id; private Integer id;
@ApiModelProperty(
value = "Use Result",
dataType = "boolean",
example = "true",
notes = "Flag indicating whether to preview table result")
private boolean useResult = true;
@ApiModelProperty( @ApiModelProperty(
value = "Use ChangeLog", value = "Use ChangeLog",
dataType = "boolean", dataType = "boolean",
......
...@@ -145,7 +145,8 @@ public class Job2MysqlHandler implements JobHandler { ...@@ -145,7 +145,8 @@ public class Job2MysqlHandler implements JobHandler {
clusterId = clusterInstance.getId(); clusterId = clusterInstance.getId();
} }
} else if (GatewayType.LOCAL.equalsValue(job.getJobConfig().getType()) } else if (GatewayType.LOCAL.equalsValue(job.getJobConfig().getType())
&& Asserts.isNotNullString(job.getJobManagerAddress())) { && Asserts.isNotNullString(job.getJobManagerAddress())
&& Asserts.isNotNullString(job.getJobId())) {
clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO( clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO(
job.getJobManagerAddress(), job.getJobManagerAddress(),
job.getJobId(), job.getJobId(),
......
...@@ -266,8 +266,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -266,8 +266,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
// 注解自调用会失效,这里通过获取对象方法绕过此限制 // 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class); TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
taskServiceBean.preCheckTask(taskDTO);
JobResult jobResult = taskServiceBean.executeJob(taskDTO); JobResult jobResult = taskServiceBean.executeJob(taskDTO);
if (Job.JobStatus.SUCCESS == jobResult.getStatus()) { if (Job.JobStatus.SUCCESS == jobResult.getStatus()) {
...@@ -288,16 +286,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -288,16 +286,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
initTenantByTaskId(debugDTO.getId()); initTenantByTaskId(debugDTO.getId());
TaskDTO taskDTO = this.getTaskInfoById(debugDTO.getId()); TaskDTO taskDTO = this.getTaskInfoById(debugDTO.getId());
taskDTO.setUseResult(debugDTO.isUseResult()); // Debug mode need return result
taskDTO.setUseResult(true);
taskDTO.setUseChangeLog(debugDTO.isUseChangeLog()); taskDTO.setUseChangeLog(debugDTO.isUseChangeLog());
taskDTO.setUseAutoCancel(debugDTO.isUseAutoCancel()); taskDTO.setUseAutoCancel(debugDTO.isUseAutoCancel());
taskDTO.setMaxRowNum(debugDTO.getMaxRowNum()); taskDTO.setMaxRowNum(debugDTO.getMaxRowNum());
// 注解自调用会失效,这里通过获取对象方法绕过此限制 // 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class); TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
taskServiceBean.preCheckTask(taskDTO);
JobResult jobResult = taskServiceBean.executeJob(taskDTO); JobResult jobResult = taskServiceBean.executeJob(taskDTO);
if (Job.JobStatus.SUCCESS == jobResult.getStatus()) { if (Job.JobStatus.SUCCESS == jobResult.getStatus()) {
log.info("Job debug success"); log.info("Job debug success");
Task task = new Task(debugDTO.getId(), jobResult.getJobInstanceId()); Task task = new Task(debugDTO.getId(), jobResult.getJobInstanceId());
......
...@@ -53,7 +53,6 @@ import cn.hutool.extra.expression.engine.jexl.JexlEngine; ...@@ -53,7 +53,6 @@ import cn.hutool.extra.expression.engine.jexl.JexlEngine;
* @since 2021/6/7 22:06 * @since 2021/6/7 22:06
*/ */
public final class VariableManager { public final class VariableManager {
public static final String VARIABLE = "variable"; public static final String VARIABLE = "variable";
static final String SHOW_VARIABLES = "SHOW VARIABLES"; static final String SHOW_VARIABLES = "SHOW VARIABLES";
private final Map<String, String> variables; private final Map<String, String> variables;
...@@ -92,17 +91,10 @@ public final class VariableManager { ...@@ -92,17 +91,10 @@ public final class VariableManager {
* *
* @param variableName name under which to register the given sql variable * @param variableName name under which to register the given sql variable
* @param variable a variable of sql to register * @param variable a variable of sql to register
* @throws CatalogException if the registration of the sql variable under the given name failed.
* But at the moment, with CatalogException, not SqlException
*/ */
public void registerVariable(String variableName, String variable) { public void registerVariable(String variableName, String variable) {
checkArgument(!StringUtils.isNullOrWhitespaceOnly(variableName), "sql variable name cannot be null or empty."); checkArgument(!StringUtils.isNullOrWhitespaceOnly(variableName), "sql variable name cannot be null or empty.");
checkNotNull(variable, "sql variable cannot be null"); checkNotNull(variable, "sql variable cannot be null");
if (variables.containsKey(variableName)) {
throw new CatalogException(format("The variable of sql %s already exists.", variableName));
}
variables.put(variableName, variable); variables.put(variableName, variable);
} }
......
...@@ -361,9 +361,6 @@ export default { ...@@ -361,9 +361,6 @@ export default {
'pages.datastudio.label.execConfig.selectDatabase.tip': 'Select the database to be used', 'pages.datastudio.label.execConfig.selectDatabase.tip': 'Select the database to be used',
'pages.datastudio.label.execConfig.maxrow': 'Maximum number of rows', 'pages.datastudio.label.execConfig.maxrow': 'Maximum number of rows',
'pages.datastudio.label.execConfig.maxrow.tip': 'The maximum number of rows of preview data', 'pages.datastudio.label.execConfig.maxrow.tip': 'The maximum number of rows of preview data',
'pages.datastudio.label.execConfig.preview.result': 'Preview Result',
'pages.datastudio.label.execConfig.preview.result.tip':
'Open the preview result, it will run synchronously and return the data result',
'pages.datastudio.label.jobConfig': 'Job Config', 'pages.datastudio.label.jobConfig': 'Job Config',
'pages.datastudio.label.jobConfig.addConfig': 'Add Config item', 'pages.datastudio.label.jobConfig.addConfig': 'Add Config item',
'pages.datastudio.label.jobConfig.addConfig.params': 'parameters', 'pages.datastudio.label.jobConfig.addConfig.params': 'parameters',
......
...@@ -349,8 +349,6 @@ export default { ...@@ -349,8 +349,6 @@ export default {
'pages.datastudio.label.execConfig.selectDatabase.tip': '选择 Sql 语句执行的数据源', 'pages.datastudio.label.execConfig.selectDatabase.tip': '选择 Sql 语句执行的数据源',
'pages.datastudio.label.execConfig.maxrow': '最大行数', 'pages.datastudio.label.execConfig.maxrow': '最大行数',
'pages.datastudio.label.execConfig.maxrow.tip': '预览数据的最大行数', 'pages.datastudio.label.execConfig.maxrow.tip': '预览数据的最大行数',
'pages.datastudio.label.execConfig.preview.result': '预览结果',
'pages.datastudio.label.execConfig.preview.result.tip': '开启预览结果,将同步运行并返回数据结果',
'pages.datastudio.label.jobConfig': '作业配置', 'pages.datastudio.label.jobConfig': '作业配置',
'pages.datastudio.label.jobConfig.addConfig': '添加配置项', 'pages.datastudio.label.jobConfig.addConfig': '添加配置项',
'pages.datastudio.label.jobConfig.addConfig.params': '参数', 'pages.datastudio.label.jobConfig.addConfig.params': '参数',
......
...@@ -126,8 +126,9 @@ const Result = (props: any) => { ...@@ -126,8 +126,9 @@ const Result = (props: any) => {
} }
const params = currentTabs.params; const params = currentTabs.params;
if (params.resultData && !isRefresh) { const consoleData = currentTabs.console;
setData(params.resultData); if (consoleData.result && !isRefresh) {
setData(consoleData.result);
} else { } else {
if (isSql(current.dialect)) { if (isSql(current.dialect)) {
// common sql // common sql
...@@ -135,13 +136,12 @@ const Result = (props: any) => { ...@@ -135,13 +136,12 @@ const Result = (props: any) => {
taskId: params.taskId taskId: params.taskId
}); });
if (res.datas) { if (res.datas) {
params.resultData = res.datas; consoleData.result = res.datas;
setData(res.datas); setData(res.datas);
} }
} else { } else {
// flink sql // flink sql
// to do: get job data by history id list, not flink jid // to do: get job data by history id list, not flink jid
console.log(current);
if (current.id) { if (current.id) {
const res = await handleGetOptionWithoutMsg(API_CONSTANTS.GET_LATEST_HISTORY_BY_ID, { const res = await handleGetOptionWithoutMsg(API_CONSTANTS.GET_LATEST_HISTORY_BY_ID, {
id: current.id id: current.id
...@@ -154,10 +154,10 @@ const Result = (props: any) => { ...@@ -154,10 +154,10 @@ const Result = (props: any) => {
}); });
const datas = tableData.datas; const datas = tableData.datas;
if (datas.success) { if (datas.success) {
params.resultData = datas; consoleData.result = datas;
setData(datas); setData(datas);
} else { } else {
params.resultData = {}; consoleData.result = {};
setData({}); setData({});
} }
} }
...@@ -170,7 +170,7 @@ const Result = (props: any) => { ...@@ -170,7 +170,7 @@ const Result = (props: any) => {
useEffect(() => { useEffect(() => {
setData({}); setData({});
loadData(); loadData();
}, [currentTabs]); }, [currentTabs, currentTabs?.console.result]);
const getColumns = (columns: string[]) => { const getColumns = (columns: string[]) => {
return columns?.map((item) => { return columns?.map((item) => {
......
...@@ -152,6 +152,7 @@ const HeaderContainer = (props: any) => { ...@@ -152,6 +152,7 @@ const HeaderContainer = (props: any) => {
}); });
messageApi.success(l('pages.datastudio.editor.debug.success')); messageApi.success(l('pages.datastudio.editor.debug.success'));
currentData.status = JOB_STATUS.RUNNING; currentData.status = JOB_STATUS.RUNNING;
if (currentTab) currentTab.console.result = res.datas.result;
saveTabs({ ...props.tabs }); saveTabs({ ...props.tabs });
}; };
......
...@@ -43,6 +43,7 @@ type TreeProps = { ...@@ -43,6 +43,7 @@ type TreeProps = {
onRightClick: (info: any) => void; onRightClick: (info: any) => void;
style?: React.CSSProperties; style?: React.CSSProperties;
selectedKeys: Key[]; selectedKeys: Key[];
selectKeyChange: (keys: Key[]) => void;
}; };
const JobTree: React.FC<TreeProps & connect> = (props) => { const JobTree: React.FC<TreeProps & connect> = (props) => {
...@@ -52,7 +53,8 @@ const JobTree: React.FC<TreeProps & connect> = (props) => { ...@@ -52,7 +53,8 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
style, style,
height, height,
onRightClick, onRightClick,
selectedKeys: selectedKey selectKeyChange,
selectedKeys
} = props; } = props;
const [searchValue, setSearchValueValue] = useState(''); const [searchValue, setSearchValueValue] = useState('');
...@@ -64,7 +66,6 @@ const JobTree: React.FC<TreeProps & connect> = (props) => { ...@@ -64,7 +66,6 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
const [expandedKeys, setExpandedKeys] = useState<Key[]>(); const [expandedKeys, setExpandedKeys] = useState<Key[]>();
const [autoExpandParent, setAutoExpandParent] = useState(true); const [autoExpandParent, setAutoExpandParent] = useState(true);
const [selectedKeys, setSelectedKeys] = useState(selectedKey);
const onChangeSearch = (e: any) => { const onChangeSearch = (e: any) => {
let { value } = e.target; let { value } = e.target;
if (!value) { if (!value) {
...@@ -110,7 +111,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => { ...@@ -110,7 +111,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
.filter((item: any, i: number, self: any) => item && self.indexOf(item) === i); .filter((item: any, i: number, self: any) => item && self.indexOf(item) === i);
setExpandedKeys(expandedKeys); setExpandedKeys(expandedKeys);
setAutoExpandParent(true); setAutoExpandParent(true);
setSelectedKeys([treeKey]); selectKeyChange([treeKey])
} }
}; };
......
...@@ -83,25 +83,6 @@ export const buildProjectTree = ( ...@@ -83,25 +83,6 @@ export const buildProjectTree = (
const currentPath = path ? [...path, item.name] : [item.name]; const currentPath = path ? [...path, item.name] : [item.name];
// 构造生命周期的值 // 构造生命周期的值
const stepValue = buildStepValue(item.task?.step); const stepValue = buildStepValue(item.task?.step);
// 渲染生命周期的徽标
const renderStepBadge = item.isLeaf && showBadge(item.type) && (
<>
<Badge.Ribbon
style={{
top: -14,
left: -57,
width: '56px',
height: '18px',
fontSize: '6px',
lineHeight: '18px'
}}
key={item.id}
placement={'start'}
text={stepValue.title}
color={stepValue.color}
/>
</>
);
// 渲染生命周期的 标记点 // 渲染生命周期的 标记点
const renderPreFixState = item.isLeaf && showBadge(item.type) && ( const renderPreFixState = item.isLeaf && showBadge(item.type) && (
<> <>
...@@ -116,7 +97,6 @@ export const buildProjectTree = ( ...@@ -116,7 +97,6 @@ export const buildProjectTree = (
const renderTitle = ( const renderTitle = (
<> <>
<Space align={'baseline'} size={2}> <Space align={'baseline'} size={2}>
{renderStepBadge}
{searchTreeNode(item.name, searchValue)} {searchTreeNode(item.name, searchValue)}
</Space> </Space>
</> </>
...@@ -138,7 +118,7 @@ export const buildProjectTree = ( ...@@ -138,7 +118,7 @@ export const buildProjectTree = (
type: item.type, type: item.type,
title: ( title: (
<> <>
{item.isLeaf && showBadge(item.type) && <>{'\u00A0'.repeat(16)}</>} {renderTitle} {item.isLeaf && showBadge(item.type) && <>{'\u00A0'.repeat(2)}</>} {renderTitle}
</> </>
), ),
fullInfo: item, fullInfo: item,
......
...@@ -39,7 +39,7 @@ import { ProjectState } from '@/types/Studio/state.d'; ...@@ -39,7 +39,7 @@ import { ProjectState } from '@/types/Studio/state.d';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { Modal, Typography } from 'antd'; import { Modal, Typography } from 'antd';
import { MenuInfo } from 'rc-menu/es/interface'; import { MenuInfo } from 'rc-menu/es/interface';
import React, { useEffect, useState } from 'react'; import React, {Key, useEffect, useState} from 'react';
import { connect } from 'umi'; import { connect } from 'umi';
const { Text } = Typography; const { Text } = Typography;
...@@ -120,6 +120,7 @@ const Project: React.FC = (props: connect) => { ...@@ -120,6 +120,7 @@ const Project: React.FC = (props: connect) => {
taskId: taskId taskId: taskId
}, },
type: 'project', type: 'project',
console: {},
subType: type subType: type
} }
}); });
...@@ -353,6 +354,7 @@ const Project: React.FC = (props: connect) => { ...@@ -353,6 +354,7 @@ const Project: React.FC = (props: connect) => {
return ( return (
<div style={{ paddingInline: 5 }}> <div style={{ paddingInline: 5 }}>
<JobTree <JobTree
selectKeyChange={(keys: Key[]) => setProjectState((prevState) => ({ ...prevState, selectedKeys: keys }))}
selectedKeys={projectState.selectedKeys} selectedKeys={projectState.selectedKeys}
onRightClick={handleRightClick} onRightClick={handleRightClick}
onNodeClick={(info: any) => onNodeClick(info)} onNodeClick={(info: any) => onNodeClick(info)}
......
...@@ -63,16 +63,6 @@ const ExecuteConfigFlinkSql = (props: any) => { ...@@ -63,16 +63,6 @@ const ExecuteConfigFlinkSql = (props: any) => {
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
> >
<ProFormGroup> <ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.preview.result')}
name='useResult'
tooltip={{
title: l('pages.datastudio.label.execConfig.preview.result.tip'),
icon: <InfoCircleOutlined />
}}
{...SWITCH_OPTIONS()}
/>
<ProFormSwitch <ProFormSwitch
label={l('pages.datastudio.label.execConfig.changelog')} label={l('pages.datastudio.label.execConfig.changelog')}
name='useChangeLog' name='useChangeLog'
...@@ -82,8 +72,6 @@ const ExecuteConfigFlinkSql = (props: any) => { ...@@ -82,8 +72,6 @@ const ExecuteConfigFlinkSql = (props: any) => {
}} }}
{...SWITCH_OPTIONS()} {...SWITCH_OPTIONS()}
/> />
</ProFormGroup>
<ProFormGroup>
<ProFormSwitch <ProFormSwitch
label={l('pages.datastudio.label.execConfig.autostop')} label={l('pages.datastudio.label.execConfig.autostop')}
name='useAutoCancel' name='useAutoCancel'
...@@ -93,6 +81,8 @@ const ExecuteConfigFlinkSql = (props: any) => { ...@@ -93,6 +81,8 @@ const ExecuteConfigFlinkSql = (props: any) => {
}} }}
{...SWITCH_OPTIONS()} {...SWITCH_OPTIONS()}
/> />
</ProFormGroup>
<ProFormGroup>
<ProFormDigit <ProFormDigit
width={'xs'} width={'xs'}
label={l('pages.datastudio.label.execConfig.maxrow')} label={l('pages.datastudio.label.execConfig.maxrow')}
......
...@@ -101,7 +101,6 @@ export type TaskType = { ...@@ -101,7 +101,6 @@ export type TaskType = {
session: string; session: string;
maxRowNum: number; maxRowNum: number;
jobName: string; jobName: string;
useResult: boolean;
useChangeLog: boolean; useChangeLog: boolean;
useAutoCancel: boolean; useAutoCancel: boolean;
}; };
...@@ -133,7 +132,6 @@ export type TaskDataType = TaskDataBaseType & Record<string, any>; ...@@ -133,7 +132,6 @@ export type TaskDataType = TaskDataBaseType & Record<string, any>;
export type DataStudioParams = { export type DataStudioParams = {
taskId: number; taskId: number;
taskData: TaskDataType; taskData: TaskDataType;
resultData: Record<string, any>;
}; };
export enum TabsPageType { export enum TabsPageType {
......
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