Browse Source

[Fix][UI Next][V1.0.0-Alpha]Fix the SQL Parameter and UDF function not shown when the datasource type is HIVE. (#9120)

3.0.0/version-upgrade
Amy0104 3 years ago committed by GitHub
parent
commit
d2138c7dfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      dolphinscheduler-ui-next/src/locales/modules/en_US.ts
  2. 5
      dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
  3. 2
      dolphinscheduler-ui-next/src/service/modules/resources/index.ts
  4. 16
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sql.ts
  5. 59
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-udfs.ts
  6. 17
      dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts
  7. 3
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts
  8. 4
      dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts

5
dolphinscheduler-ui-next/src/locales/modules/en_US.ts

@ -914,7 +914,10 @@ const project = {
title_tips: 'Please enter the title of email', title_tips: 'Please enter the title of email',
alarm_group: 'Alarm group', alarm_group: 'Alarm group',
alarm_group_tips: 'Alarm group required', alarm_group_tips: 'Alarm group required',
integer_tips: 'Please enter a positive integer' integer_tips: 'Please enter a positive integer',
sql_parameter: 'SQL Parameter',
format_tips: 'Please enter format',
udf_function: 'UDF Function'
} }
} }

5
dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts

@ -904,7 +904,10 @@ const project = {
title_tips: '请输入邮件主题', title_tips: '请输入邮件主题',
alarm_group: '告警组', alarm_group: '告警组',
alarm_group_tips: '告警组必填', alarm_group_tips: '告警组必填',
integer_tips: '请输入一个正整数' integer_tips: '请输入一个正整数',
sql_parameter: 'sql参数',
format_tips: '请输入格式为',
udf_function: 'UDF函数'
} }
} }

2
dolphinscheduler-ui-next/src/service/modules/resources/index.ts

@ -142,7 +142,7 @@ export function queryUdfFuncListPaging(params: ListReq): any {
}) })
} }
export function queryUdfFuncList(params: IdReq & ListReq): any { export function queryUdfFuncList(params: { type: 'HIVE' | 'SPARK' }): any {
return axios({ return axios({
url: '/resources/udf-func/list', url: '/resources/udf-func/list',
method: 'get', method: 'get',

16
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sql.ts

@ -14,17 +14,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { ref, onMounted } from 'vue' import { ref, onMounted, computed } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { queryResourceList } from '@/service/modules/resources' import { queryResourceList } from '@/service/modules/resources'
import { removeUselessChildren } from '@/utils/tree-format' import { removeUselessChildren } from '@/utils/tree-format'
import { useUdfs } from './use-udfs'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
export function useSql(model: { [field: string]: any }): IJsonItem[] { export function useSql(model: { [field: string]: any }): IJsonItem[] {
const { t } = useI18n() const { t } = useI18n()
const options = ref([]) const options = ref([])
const loading = ref(false) const loading = ref(false)
const hiveSpan = computed(() => (model.type === 'HIVE' ? 24 : 0))
const getResourceList = async () => { const getResourceList = async () => {
if (loading.value) return if (loading.value) return
@ -40,6 +41,16 @@ export function useSql(model: { [field: string]: any }): IJsonItem[] {
}) })
return [ return [
{
type: 'input',
field: 'connParams',
name: t('project.node.sql_parameter'),
props: {
placeholder:
t('project.node.format_tips') + ' key1=value1;key2=value2...'
},
span: hiveSpan
},
{ {
type: 'editor', type: 'editor',
field: 'sql', field: 'sql',
@ -50,6 +61,7 @@ export function useSql(model: { [field: string]: any }): IJsonItem[] {
message: t('project.node.sql_empty_tips') message: t('project.node.sql_empty_tips')
} }
}, },
useUdfs(model),
{ {
type: 'tree-select', type: 'tree-select',
field: 'resourceList', field: 'resourceList',

59
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-udfs.ts

@ -0,0 +1,59 @@
/*
* 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 { ref, watch, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { queryUdfFuncList } from '@/service/modules/resources'
import type { IJsonItem } from '../types'
export function useUdfs(model: { [field: string]: any }): IJsonItem {
const { t } = useI18n()
const options = ref([])
const loading = ref(false)
const span = computed(() => (['HIVE', 'SPARK'].includes(model.type) ? 24 : 0))
const getUdfs = async () => {
if (loading.value) return
loading.value = true
const res = await queryUdfFuncList({ type: model.type })
options.value = res.map((udf: { id: number; funcName: string }) => ({
value: udf.id,
label: udf.funcName
}))
loading.value = false
}
watch(
() => model.type,
(value) => {
if (['HIVE', 'SPARK'].includes(value)) {
getUdfs()
}
}
)
return {
type: 'select',
field: 'udfs',
options: options,
name: t('project.node.udf_function'),
props: {
multiple: true,
loading
},
span
}
}

17
dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts

@ -181,8 +181,14 @@ export function formatParams(data: INodeData): {
taskParams.postStatements = data.postStatements taskParams.postStatements = data.postStatements
taskParams.sendEmail = data.sendEmail taskParams.sendEmail = data.sendEmail
taskParams.displayRows = data.displayRows taskParams.displayRows = data.displayRows
taskParams.title = data.title if (data.sendEmail) {
taskParams.groupId = data.groupId taskParams.title = data.title
taskParams.groupId = data.groupId
}
if (data.type === 'HIVE') {
if (data.udfs) taskParams.udfs = data.udfs.join(',')
taskParams.connParams = data.connParams
}
} }
if (data.taskType === 'PROCEDURE') { if (data.taskType === 'PROCEDURE') {
@ -476,10 +482,13 @@ export function formatModel(data: ITaskData) {
} }
if (data.taskParams?.conditionResult?.successNode?.length) { if (data.taskParams?.conditionResult?.successNode?.length) {
params.successBranch = data.taskParams?.conditionResult.successNode[0] params.successBranch = data.taskParams.conditionResult.successNode[0]
} }
if (data.taskParams?.conditionResult?.failedNode?.length) { if (data.taskParams?.conditionResult?.failedNode?.length) {
params.failedBranch = data.taskParams?.conditionResult.failedNode[0] params.failedBranch = data.taskParams.conditionResult.failedNode[0]
}
if (data.taskParams?.udfs) {
params.udfs = data.taskParams.udfs?.split(',')
} }
return params return params
} }

3
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts

@ -49,7 +49,8 @@ export function useSql({
sql: '', sql: '',
sqlType: '0', sqlType: '0',
preStatements: [], preStatements: [],
postStatements: [] postStatements: [],
udfs: []
} as INodeData) } as INodeData)
let extra: IJsonItem[] = [] let extra: IJsonItem[] = []

4
dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts

@ -284,6 +284,8 @@ interface ITaskParams {
successNode?: number[] successNode?: number[]
failedNode?: number[] failedNode?: number[]
} }
udfs?: string
connParams?: string
} }
interface INodeData interface INodeData
@ -296,6 +298,7 @@ interface INodeData
| 'dependence' | 'dependence'
| 'sparkParameters' | 'sparkParameters'
| 'conditionResult' | 'conditionResult'
| 'udfs'
>, >,
ISqoopTargetData, ISqoopTargetData,
ISqoopSourceData, ISqoopSourceData,
@ -332,6 +335,7 @@ interface INodeData
definition?: object definition?: object
successBranch?: number successBranch?: number
failedBranch?: number failedBranch?: number
udfs?: string[]
} }
interface ITaskData interface ITaskData

Loading…
Cancel
Save