-
Notifications
You must be signed in to change notification settings - Fork 26
feat: pipeline ddl #571
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
feat: pipeline ddl #571
Changes from 4 commits
07d7ab3
b19576d
68c337f
036bd4e
52c96ca
8810a62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,12 @@ a-layout.full-height-layout.pipefile-view( | |
| Delete | ||
a-button(type="primary" size="small" @click="handleSave") | ||
| Save | ||
a-card.pipeline-actions-card(v-if="!isCreating") | ||
a-button(type="text" size="small" @click="handleIngest") | ||
| Ingest With Pipeline | ||
a-button(type="text" size="small" @click="showCreateTableModal") | ||
| Create Table from Pipeline | ||
|
||
a-form( | ||
ref="formRef" | ||
layout="vertical" | ||
|
@@ -39,13 +45,7 @@ a-layout.full-height-layout.pipefile-view( | |
a-form-item(v-if="!isCreating" field="version" label="Version") | ||
a-space | ||
| {{ currFile.version }} | ||
a-button( | ||
v-if="!isCreating" | ||
type="text" | ||
size="small" | ||
@click="handleIngest" | ||
) | ||
| Ingest With Pipeline | ||
|
||
a-form-item(field="content" label="Yaml Content") | ||
template(#help) | ||
div | ||
|
@@ -143,6 +143,9 @@ a-layout.full-height-layout.pipefile-view( | |
:tabSize="2" | ||
:disabled="true" | ||
) | ||
|
||
// Create Table Modal | ||
CreateTableModal(ref="createTableModalRef" :pipeline-name="currFile.name" @tableCreated="() => {}") | ||
|
||
</template> | ||
|
||
<script setup name="PipeFileView" lang="ts"> | ||
|
@@ -155,6 +158,8 @@ a-layout.full-height-layout.pipefile-view( | |
import type { ColumnType } from '@/types/query' | ||
import router from '@/router' | ||
import DataTable from '@/components/data-table/index.vue' | ||
import YMLEditorSimple from '@/components/yml-editor.vue' | ||
import CreateTableModal from './create-table-modal/index.vue' | ||
import { toObj } from '../query/until' | ||
|
||
const emit = defineEmits(['refresh', 'del']) | ||
|
@@ -366,6 +371,8 @@ transform: | |
|
||
const ymlError = ref('') | ||
|
||
const createTableModalRef = ref() | ||
|
||
function getData() { | ||
const name = props.filename | ||
if (name) { | ||
|
@@ -384,6 +391,13 @@ transform: | |
}, | ||
}) | ||
} | ||
|
||
// Show create table modal | ||
const showCreateTableModal = () => { | ||
if (createTableModalRef.value?.open) { | ||
createTableModalRef.value.open() | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
|
@@ -401,7 +415,7 @@ transform: | |
height: calc(100vh - 238px); // Taller for creating mode (no version field) | ||
|
||
&.editing { | ||
height: calc(100vh - 238px); // Shorter for editing mode (has version field) | ||
height: calc(100vh - 298px); // Shorter for editing mode (has version field) | ||
} | ||
} | ||
|
||
|
@@ -588,4 +602,18 @@ transform: | |
margin: 10px 0 0; | ||
position: relative; | ||
} | ||
|
||
// =================== | ||
// PIPELINE ACTIONS CARD | ||
// =================== | ||
.pipeline-actions-card { | ||
border: 1px solid var(--color-border-2); | ||
border-radius: 4px; | ||
margin: 10px 10px 0 10px; | ||
padding: 10px 2px; | ||
|
||
:deep(.arco-card-body) { | ||
padding: 0; | ||
} | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,133 @@ | ||||||||||||||||||||||||||||||||||||
<template lang="pug"> | ||||||||||||||||||||||||||||||||||||
a-modal( | ||||||||||||||||||||||||||||||||||||
v-model:visible="visible" | ||||||||||||||||||||||||||||||||||||
title="Create Pipeline Ingestion Table" | ||||||||||||||||||||||||||||||||||||
:width="700" | ||||||||||||||||||||||||||||||||||||
@ok="handleCreate" | ||||||||||||||||||||||||||||||||||||
@cancel="visible = false" | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
template(#footer) | ||||||||||||||||||||||||||||||||||||
a-space | ||||||||||||||||||||||||||||||||||||
a-button(@click="visible = false") Cancel | ||||||||||||||||||||||||||||||||||||
a-button(type="primary" :loading="creating" @click="handleCreate") Create Table | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
.create-table-content | ||||||||||||||||||||||||||||||||||||
a-space( | ||||||||||||||||||||||||||||||||||||
style="background-color: var(--color-fill-2); padding: 16px; border-radius: 4px; width: 100%; margin-bottom: 16px" | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
span.label Table Name | ||||||||||||||||||||||||||||||||||||
a-input(v-model="tableName" placeholder="Enter table name" style="width: 200px; margin-right: 8px") | ||||||||||||||||||||||||||||||||||||
a-button(type="outline" :loading="loadingDDL" @click="handleGetDDL") Get CREATE TABLE SQL from Pipeline | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
.sql-content-section | ||||||||||||||||||||||||||||||||||||
a-form( | ||||||||||||||||||||||||||||||||||||
ref="formRef" | ||||||||||||||||||||||||||||||||||||
layout="vertical" | ||||||||||||||||||||||||||||||||||||
:model="formData" | ||||||||||||||||||||||||||||||||||||
:rules="rules" | ||||||||||||||||||||||||||||||||||||
@submit="handleCreate" | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
a-form-item(field="createTableSQL" label="CREATE TABLE SQL" required) | ||||||||||||||||||||||||||||||||||||
YMLEditorSimple( | ||||||||||||||||||||||||||||||||||||
v-model="formData.createTableSQL" | ||||||||||||||||||||||||||||||||||||
language="sql" | ||||||||||||||||||||||||||||||||||||
style="width: 100%; height: 300px; border: 1px solid var(--color-border); border-radius: 4px; overflow: hidden" | ||||||||||||||||||||||||||||||||||||
placeholder="CREATE TABLE SQL" | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
</template> | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
<script setup lang="ts"> | ||||||||||||||||||||||||||||||||||||
import { ref, reactive, computed, defineExpose } from 'vue' | ||||||||||||||||||||||||||||||||||||
import { Notification } from '@arco-design/web-vue' | ||||||||||||||||||||||||||||||||||||
import YMLEditorSimple from '@/components/yml-editor.vue' | ||||||||||||||||||||||||||||||||||||
import editorAPI from '@/api/editor' | ||||||||||||||||||||||||||||||||||||
import { getPipelineDDL } from '@/api/pipeline' | ||||||||||||||||||||||||||||||||||||
const props = defineProps<{ pipelineName: string }>() | ||||||||||||||||||||||||||||||||||||
const emit = defineEmits<{ (e: 'tableCreated'): void }>() | ||||||||||||||||||||||||||||||||||||
const visible = ref(false) | ||||||||||||||||||||||||||||||||||||
const creating = ref(false) | ||||||||||||||||||||||||||||||||||||
const loadingDDL = ref(false) | ||||||||||||||||||||||||||||||||||||
const tableName = ref('') | ||||||||||||||||||||||||||||||||||||
const formRef = ref() | ||||||||||||||||||||||||||||||||||||
const formData = reactive({ | ||||||||||||||||||||||||||||||||||||
createTableSQL: '', | ||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||
const rules = { | ||||||||||||||||||||||||||||||||||||
createTableSQL: [ | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
required: true, | ||||||||||||||||||||||||||||||||||||
message: 'Please enter table creation SQL', | ||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
function open() { | ||||||||||||||||||||||||||||||||||||
tableName.value = '' | ||||||||||||||||||||||||||||||||||||
formData.createTableSQL = '' | ||||||||||||||||||||||||||||||||||||
visible.value = true | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
defineExpose({ open }) | ||||||||||||||||||||||||||||||||||||
const handleGetDDL = async () => { | ||||||||||||||||||||||||||||||||||||
if (!tableName.value.trim()) { | ||||||||||||||||||||||||||||||||||||
Notification.warning('Please enter a table name') | ||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
if (!props.pipelineName) { | ||||||||||||||||||||||||||||||||||||
Notification.warning('Pipeline name is required to get DDL') | ||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||
loadingDDL.value = true | ||||||||||||||||||||||||||||||||||||
formData.createTableSQL = await getPipelineDDL(props.pipelineName, tableName.value) | ||||||||||||||||||||||||||||||||||||
} finally { | ||||||||||||||||||||||||||||||||||||
loadingDDL.value = false | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
const handleCreate = async () => { | ||||||||||||||||||||||||||||||||||||
if (!formRef.value) return | ||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||
const valid = await formRef.value.validate() | ||||||||||||||||||||||||||||||||||||
if (valid !== undefined) { | ||||||||||||||||||||||||||||||||||||
// Validation failed, valid contains the error details | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment mentions that
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
creating.value = true | ||||||||||||||||||||||||||||||||||||
await editorAPI.runSQL(formData.createTableSQL) | ||||||||||||||||||||||||||||||||||||
emit('tableCreated') | ||||||||||||||||||||||||||||||||||||
visible.value = false | ||||||||||||||||||||||||||||||||||||
tableName.value = '' | ||||||||||||||||||||||||||||||||||||
formData.createTableSQL = '' | ||||||||||||||||||||||||||||||||||||
Notification.success('SQL executed successfully') | ||||||||||||||||||||||||||||||||||||
} finally { | ||||||||||||||||||||||||||||||||||||
creating.value = false | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
<style lang="less" scoped> | ||||||||||||||||||||||||||||||||||||
.create-table-content { | ||||||||||||||||||||||||||||||||||||
p { | ||||||||||||||||||||||||||||||||||||
margin-bottom: 16px; | ||||||||||||||||||||||||||||||||||||
color: var(--color-text-2); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
:deep(.arco-form-item-label) { | ||||||||||||||||||||||||||||||||||||
font-weight: 500; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
:deep(.arco-form-item-help) { | ||||||||||||||||||||||||||||||||||||
margin-top: 4px; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing nested property
sql.sql
without null/undefined checks could cause runtime errors if the API response structure is unexpected. Consider using optional chaining:return result.sql?.sql
Copilot uses AI. Check for mistakes.