This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 8614b2b46 [KYUUBI #6248] Web SQL Editor supports run SQL snippets
8614b2b46 is described below
commit 8614b2b46bb0fa0f7d3b7cafbd32789506557f04
Author: dupeng <[email protected]>
AuthorDate: Sun Apr 7 23:33:57 2024 +0800
[KYUUBI #6248] Web SQL Editor supports run SQL snippets
# :mag: Description
when some text is selected, only send the selected text.
## Issue References ๐
This pull request fixes #6248
## Describe Your Solution ๐ง
The Monaco Editor API is called to get the selected SQL statement, and
without any other dependency.
<img width="581" alt="image"
src="https://github.com/apache/kyuubi/assets/34719039/ce6ac5ae-b1fc-4778-a57e-dfda9ad51275">
## Types of changes :bookmark:
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklist ๐
- [ ] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #6272 from dupen01/issue-6248.
Closes #6248
67d47cd4e [dupeng] Improved nonempty judgment
e0767bb64 [dupeng] Finished task "Web SQL Editor supports run SQL snippets
#6248"
Authored-by: dupeng <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../web-ui/src/components/monaco-editor/index.vue | 17 +++++++++++++++++
.../web-ui/src/views/editor/components/Editor.vue | 6 ++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/kyuubi-server/web-ui/src/components/monaco-editor/index.vue
b/kyuubi-server/web-ui/src/components/monaco-editor/index.vue
index 65a2dba34..c5ae134b9 100644
--- a/kyuubi-server/web-ui/src/components/monaco-editor/index.vue
+++ b/kyuubi-server/web-ui/src/components/monaco-editor/index.vue
@@ -105,6 +105,20 @@
})
emit('editorMounted', editor)
}
+ const getSelectValue = () => {
+ const selection = editor.getSelection()
+ if (!selection) {
+ return ''
+ }
+ const range = {
+ startLineNumber: selection.selectionStartLineNumber,
+ startColumn: selection.selectionStartColumn,
+ endLineNumber: selection.positionLineNumber,
+ endColumn: selection.positionColumn
+ }
+ const model = editor.getModel()
+ return model?.getValueInRange(range)
+ }
watch(
() => props.modelValue,
(newValue) => {
@@ -146,4 +160,7 @@
onMounted(() => {
init()
})
+ defineExpose({
+ getSelectValue
+ })
</script>
diff --git a/kyuubi-server/web-ui/src/views/editor/components/Editor.vue
b/kyuubi-server/web-ui/src/views/editor/components/Editor.vue
index c1bdbaa09..2f4a1b3a5 100644
--- a/kyuubi-server/web-ui/src/views/editor/components/Editor.vue
+++ b/kyuubi-server/web-ui/src/views/editor/components/Editor.vue
@@ -55,6 +55,7 @@
</el-space>
<section>
<MonacoEditor
+ ref="monacoEditor"
v-model="editorVariables.content"
:language="editorVariables.language"
:theme="theme"
@@ -113,6 +114,7 @@
})
const limit = ref(10)
const sqlResult: Ref<any[] | null> = ref(null)
+ const monacoEditor = ref()
const sqlLog = ref('')
const activeTab = ref('result')
const resultLoading = ref(false)
@@ -156,10 +158,10 @@
if (!openSessionResponse) return
sessionIdentifier.value = openSessionResponse.identifier
}
-
+ const selectValue = monacoEditor.value.getSelectValue()
const runSqlResponse: IResponse = await runSql(
{
- statement: editorVariables.content,
+ statement: selectValue || editorVariables.content,
runAsync: false
},
sessionIdentifier.value