Skip to content

Commit

Permalink
[Optimize][Web] Optimize blood relationship acquisition, add Savepoin…
Browse files Browse the repository at this point in the history
…t, optimize udf class name display (#4024)

Co-authored-by: zackyoungh <[email protected]>
  • Loading branch information
zackyoungh and zackyoungh authored Dec 6, 2024
1 parent be98771 commit 0da1714
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.dinky.data.dto;

import org.dinky.data.model.ext.TaskExtConfig;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
Expand All @@ -41,9 +43,6 @@ public class StudioLineageDTO extends AbstractStatementDTO {
notes = "Flag indicating whether to use Statement Set")
private Boolean statementSet;

@ApiModelProperty(value = "Type", dataType = "Integer", example = "1", notes = "The type of the SQL query")
private Integer type;

@ApiModelProperty(value = "Dialect", dataType = "String", example = "MySQL", notes = "The SQL dialect")
private String dialect;

Expand All @@ -56,4 +55,10 @@ public class StudioLineageDTO extends AbstractStatementDTO {

@ApiModelProperty(value = "Task ID", dataType = "Integer", example = "1", notes = "The identifier of the task")
private Integer taskId;

@ApiModelProperty(
value = "Configuration JSON",
dataType = "TaskExtConfig",
notes = "Extended configuration in JSON format for the task")
private TaskExtConfig configJson;
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public LineageResult getLineage(StudioLineageDTO studioCADTO) {
TaskDTO taskDTO = taskService.getTaskInfoById(studioCADTO.getTaskId());
taskDTO.setStatement(taskService.buildEnvSql(taskDTO) + studioCADTO.getStatement());
JobConfig jobConfig = taskDTO.getJobConfig();
jobConfig.setUdfRefer(studioCADTO.getConfigJson().getUdfReferMaps());
jobConfig.setConfigJson(studioCADTO.getConfigJson().getCustomConfigMaps());

return LineageBuilder.getColumnLineageByLogicalPlan(taskDTO.getStatement(), jobConfig);
}
}
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ export default {
'pages.datastudio.label.jobInfo.versionId': 'Version number',
'pages.datastudio.label.jobInfo.firstLevelOwner': 'Owner',
'pages.datastudio.label.jobInfo.secondLevelOwners': 'Maintainer',
'pages.datastudio.label.jobInfo.className': 'ClassName',
'pages.datastudio.label.result.query.latest.data': 'Get the latest data',
'pages.datastudio.label.result.query.latest.data.truncate':
'The data is too long to be displayed in full',
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ export default {
'pages.datastudio.label.jobInfo.versionId': '版本号',
'pages.datastudio.label.jobInfo.firstLevelOwner': '责任人',
'pages.datastudio.label.jobInfo.secondLevelOwners': '维护人',
'pages.datastudio.label.jobInfo.className': '类名',
'pages.datastudio.label.result.query.latest.data': '获取最新数据',
'pages.datastudio.label.result.query.latest.data.truncate': '数据过长无法全部显示',
'pages.datastudio.label.version': '版本历史',
Expand Down
100 changes: 100 additions & 0 deletions dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/SavePoint.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import { postAll } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints';
import { l } from '@/utils/intl';
import { ActionType, ProColumns, ProDescriptions, ProTable } from '@ant-design/pro-components';
import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import { Drawer } from 'antd';
import { useRef, useState } from 'react';

export type SavePointData = {
id: number;
taskId: number;
name: string;
type: string;
path: string;
createTime: Date;
};

export const SavePoint = (props: { taskId: number }) => {
const { taskId } = props;

const [row, setRow] = useState<SavePointData>();
const actionRef = useRef<ActionType>();
actionRef.current?.reloadAndRest?.();

const columns: ProDescriptionsItemProps<SavePointData>[] | ProColumns<SavePointData>[] = [
{
title: l('pages.task.savePointPath'),
dataIndex: 'path',
hideInForm: true,
hideInSearch: true
},
{
title: l('global.table.createTime'),
dataIndex: 'createTime',
valueType: 'dateTime',
hideInForm: true,
hideInSearch: true,
render: (dom: any, entity: SavePointData) => {
return <a onClick={() => setRow(entity)}>{dom}</a>;
}
}
];

return (
<>
<ProTable<SavePointData>
className={'datastudio-theme'}
actionRef={actionRef}
rowKey='id'
request={(params, sorter, filter) =>
postAll(API_CONSTANTS.GET_SAVEPOINT_LIST, { ...params, sorter, filter })
}
params={{ taskId }}
columns={columns as ProColumns<SavePointData>[]}
search={false}
/>
<Drawer
width={600}
open={!!row}
onClose={() => {
setRow(undefined);
}}
closable={false}
>
{row?.name && (
<ProDescriptions<SavePointData>
column={2}
title={row?.name}
request={async () => ({
data: row || {}
})}
params={{
id: row?.name
}}
columns={columns as ProDescriptionsItemProps<SavePointData>[]}
/>
)}
</Drawer>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import Paragraph from 'antd/es/typography/Paragraph';
import { TaskState } from '@/pages/DataStudio/type';
import { showFirstLevelOwner, showSecondLevelOwners } from '@/pages/DataStudio/function';
import { UserBaseInfo } from '@/types/AuthCenter/data';
import { isUDF } from '@/pages/DataStudio/Toolbar/Project/function';

export const TaskInfo = (props: { params: TaskState; users: UserBaseInfo.User[] }) => {
const {
params: { taskId, name, dialect, versionId, firstLevelOwner, secondLevelOwners },
params: { taskId, name, dialect, versionId, firstLevelOwner, secondLevelOwners, savePointPath },
users
} = props;

console.log(savePointPath);
return (
<div style={{ paddingInline: 8 }}>
<Descriptions bordered size='small' column={1}>
Expand All @@ -51,6 +53,11 @@ export const TaskInfo = (props: { params: TaskState; users: UserBaseInfo.User[]
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.secondLevelOwners')}>
{showSecondLevelOwners(secondLevelOwners, users)}
</Descriptions.Item>
{isUDF(dialect) && (
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.className')}>
{savePointPath}
</Descriptions.Item>
)}
</Descriptions>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import { SseData, Topic } from '@/models/UseWebSocketModel';
import { ResourceInfo } from '@/types/RegCenter/data';
import { buildResourceTreeDataAtTreeForm } from '@/pages/RegCenter/Resource/components/FileTree/function';
import { ProFormDependency } from '@ant-design/pro-form';
import { SavePoint } from '@/pages/DataStudio/CenterTabContent/SqlTask/SavePoint';

export type FlinkSqlProps = {
showDesc: boolean;
Expand Down Expand Up @@ -390,6 +391,11 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => {
/>
)
});
rightToolbarItem.push({
label: l('menu.datastudio.savePoint'),
key: 'savePoint',
children: <SavePoint taskId={currentState.taskId} />
});
}

rightToolbarItem.push({
Expand Down Expand Up @@ -443,17 +449,17 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => {
}, [currentState, updateAction]);

const handleLineage = useCallback(async () => {
const { type, dialect, databaseId, statement, envId, fragment, taskId } = currentState;
const { dialect, databaseId, statement, envId, fragment, taskId } = currentState;
const params: StudioLineageParams = {
type: 1, // todo: 暂时写死 ,后续优化
dialect: dialect,
envId: envId ?? -1,
fragment: fragment,
statement: statement,
statementSet: true,
databaseId: databaseId ?? 0,
variables: {},
taskId: taskId
taskId: taskId,
configJson: currentState.configJson
};
const data = (await getDataByParams(
API_CONSTANTS.STUDIO_GET_LINEAGE,
Expand Down
2 changes: 2 additions & 0 deletions dinky-web/src/pages/DataStudio/Toolbar/Resource/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ const Resource = (props: {
ghost
size={'small'}
bodyStyle={{ height: 'calc(100vh - 180px)', overflow: 'auto' }}
className={'datastudio-theme'}
>
<Result
status='warning'
Expand All @@ -333,6 +334,7 @@ const Resource = (props: {
<>
<ProCard
style={{ height: '100%' }}
className={'datastudio-theme'}
bodyStyle={{
paddingTop: 10,
paddingInline: 5,
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/pages/DataStudio/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ export type TaskState = {
* en: Task Lineage params.
*/
export interface StudioLineageParams {
type: number;
statementSet: boolean;
dialect: string;
databaseId: number;
Expand All @@ -288,6 +287,7 @@ export interface StudioLineageParams {
fragment: boolean;
variables: any;
taskId: number;
configJson: TaskExtConfig;
}
export type TreeVo = {
name: string;
Expand Down

0 comments on commit 0da1714

Please sign in to comment.