Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions kyuubi-server/web-ui/src/api/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
*/

import request from '@/utils/request'
import type {
IOpenSessionRequest,
IRunSqlRequest,
IGetSqlRowsetRequest,
IGetSqlMetadataRequest
} from './types'

export function openSession(data: Map<string, string>): any {
export function openSession(data: IOpenSessionRequest): any {
return request({
url: 'api/v1/sessions',
method: 'post',
Expand All @@ -32,31 +38,31 @@ export function closeSession(identifier: string): any {
})
}

export function runSql(data: any, identifier: string): any {
export function runSql(data: IRunSqlRequest, identifier: string): any {
return request({
url: `api/v1/sessions/${identifier}/operations/statement`,
method: 'post',
data
})
}

export function getSqlRowset(params: any): any {
export function getSqlRowset(params: IGetSqlRowsetRequest): any {
return request({
url: `api/v1/operations/${params.operationHandleStr}/rowset`,
method: 'get',
params
})
}

export function getSqlMetadata(params: any): any {
export function getSqlMetadata(params: IGetSqlMetadataRequest): any {
return request({
url: `api/v1/operations/${params.operationHandleStr}/resultsetmetadata`,
method: 'get',
params
})
}

export function log(identifier: string): any {
export function getLog(identifier: string): any {
return request({
url: `api/v1/operations/${identifier}/log`,
method: 'get'
Expand Down
42 changes: 42 additions & 0 deletions kyuubi-server/web-ui/src/api/editor/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.
*/

interface IOpenSessionRequest {
'kyuubi.engine.type': string
}

interface IRunSqlRequest {
statement: string
runAsync: boolean
}

interface IGetSqlRowsetRequest {
operationHandleStr: string
fetchorientation: 'FETCH_NEXT'
maxrows: number
}

interface IGetSqlMetadataRequest {
operationHandleStr: string
}

export {
IOpenSessionRequest,
IRunSqlRequest,
IGetSqlRowsetRequest,
IGetSqlMetadataRequest
}
6 changes: 4 additions & 2 deletions kyuubi-server/web-ui/src/locales/en_US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
engine_ui: 'Engine UI',
failure_reason: 'Failure Reason',
session_properties: 'Session Properties',
no_data: 'No data yet',
no_data: 'No data',
run_sql_tips: 'Run a sql to get result',
operation: {
text: 'Operation',
Expand All @@ -56,6 +56,8 @@ export default {
close_failed: 'Close {name} Failed',
cancel_succeeded: 'Cancel {name} Succeeded',
cancel_failed: 'Cancel {name} Failed',
run_failed: 'Run Sql Failed'
run_failed: 'Run Sql Failed',
get_sql_log_failed: 'Get Sql Log Failed',
get_sql_result_failed: 'Get Sql Result Failed'
}
}
4 changes: 3 additions & 1 deletion kyuubi-server/web-ui/src/locales/zh_CN/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export default {
close_failed: '关闭 {name} 失败',
cancel_succeeded: '取消 {name} 成功',
cancel_failed: '取消 {name} 失败',
run_failed: '运行失败'
run_failed: '运行失败',
get_sql_log_failed: '获取sql日志失败',
get_sql_result_failed: '获取sql结果失败'
}
}
24 changes: 18 additions & 6 deletions kyuubi-server/web-ui/src/views/editor/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
<template>
<div class="editor">
<el-space>
<el-select v-model="param.engineType" :placeholder="$t('engine_type')">
<el-select
v-model="param.engineType"
disabled
:placeholder="$t('engine_type')">
<el-option
v-for="item in getEngineType()"
:key="item"
Expand All @@ -43,7 +46,7 @@
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item v-for="l in limits" :key="l" :command="l">
<el-dropdown-item v-for="l in [10, 50, 100]" :key="l" :command="l">
Limit: {{ l }}
</el-dropdown-item>
</el-dropdown-menu>
Expand Down Expand Up @@ -87,7 +90,7 @@
runSql,
getSqlRowset,
getSqlMetadata,
log
getLog
} from '@/api/editor'
import type { IResponse, ISqlResult, IFields, ILog } from './types'

Expand All @@ -96,7 +99,6 @@
engineType: 'SPARK_SQL'
})
const limit = ref(10)
const limits = ref([10, 50, 100])
const sqlResult: Ref<any[] | null> = ref(null)
const sqlLog = ref('')
const activeTab = ref('result')
Expand Down Expand Up @@ -166,17 +168,27 @@
})
})
.catch(() => {
ElMessage({
message: t('message.get_sql_result_failed'),
type: 'error'
})
sqlResult.value = []
})
.finally(() => {
resultLoading.value = false
})

sqlLog.value = await log(runSqlResponse.identifier)
sqlLog.value = await getLog(runSqlResponse.identifier)
.then((res: ILog) => {
return res?.logRowSet?.join('\r\n')
})
.catch(() => '')
.catch(() => {
ElMessage({
message: t('message.get_sql_log_failed'),
type: 'error'
})
return ''
})
.finally(() => {
logLoading.value = false
})
Expand Down