Skip to content
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
49 changes: 39 additions & 10 deletions data-agent-frontend/src/components/agent/DataSourceConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,18 @@
<el-col :span="12">
<div class="form-item">
<label>数据源类型 *</label>
<!-- todo: 改为后端动态获取-->
<el-select
v-model="newDatasource.type"
placeholder="请选择数据源类型"
style="width: 100%"
size="large"
>
<el-option key="mysql" label="MySQL" value="mysql" />
<el-option key="postgresql" label="PostgreSQL" value="postgresql" />
<el-option key="sqlserver" label="SQL Server" value="sqlserver" />
<el-option key="dameng" label="达梦(Dameng)" value="dameng" />
<el-option key="oracle" label="Oracle" value="oracle" />
<el-option
v-for="type in datasourceTypes"
:key="type.typeName"
:label="type.displayName"
:value="type.typeName"
/>
</el-select>
</div>
</el-col>
Expand Down Expand Up @@ -402,9 +402,12 @@
style="width: 100%"
size="large"
>
<el-option key="mysql" label="MySQL" value="mysql" />
<el-option key="postgresql" label="PostgreSQL" value="postgresql" />
<el-option key="dameng" label="达梦(Dameng)" value="dameng" />
<el-option
v-for="type in datasourceTypes"
:key="type.typeName"
:label="type.displayName"
:value="type.typeName"
/>
</el-select>
</div>
</el-col>
Expand Down Expand Up @@ -804,7 +807,7 @@
Edit,
} from '@element-plus/icons-vue';
import datasourceService from '@/services/datasource';
import { Datasource, AgentDatasource } from '@/services/datasource';
import { Datasource, AgentDatasource, DatasourceType } from '@/services/datasource';
import { ApiResponse } from '@/services/common';
import { ElMessage, ElMessageBox } from 'element-plus';
import agentDatasourceService from '@/services/agentDatasource';
Expand Down Expand Up @@ -860,14 +863,24 @@
const targetColumnList: Ref<string[]> = ref([]);
const savingForeignKeys: Ref<boolean> = ref(false);

// 数据源类型列表
const datasourceTypes: Ref<DatasourceType[]> = ref([]);

watch(dialogVisible, newValue => {
if (newValue) {
loadAllDatasource();
loadDatasourceTypes();
newDatasource.value = { port: 3306 } as Datasource;
schemaName.value = '';
}
});

watch(editDialogVisible, newValue => {
if (newValue) {
loadDatasourceTypes();
}
});

// 初始化Agent数据源列表
const loadAgentDatasource = async () => {
selectedDatasourceId.value = null;
Expand Down Expand Up @@ -910,6 +923,19 @@
}
};

// 加载数据源类型列表
const loadDatasourceTypes = async () => {
try {
const response = await datasourceService.getDatasourceTypes();
if (response.success && response.data) {
datasourceTypes.value = response.data;
}
} catch (error) {
ElMessage.error('加载数据源类型失败');
console.error('Failed to load datasource types:', error);
}
};

// 初始化Agent数据源
const initAgentDatasource = async () => {
initStatus.value = true;
Expand Down Expand Up @@ -1586,6 +1612,9 @@
// PostgreSQL/Oracle Schema字段
schemaName,
schemaNameEdit,
// 数据源类型
datasourceTypes,
loadDatasourceTypes,
// 逻辑外键管理
Connection,
Link,
Expand Down
15 changes: 15 additions & 0 deletions data-agent-frontend/src/services/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ export interface AgentDatasource {
selectTables?: string[];
}

// 定义数据源类型接口
export interface DatasourceType {
code: number;
typeName: string;
dialect: string;
protocol: string;
displayName: string;
}

const API_BASE_URL = '/api/datasource';

class DatasourceService {
Expand Down Expand Up @@ -111,6 +120,12 @@ class DatasourceService {
const response = await axios.post<ApiResponse<boolean>>(`${API_BASE_URL}/${id}/test`);
return response.data;
}

// 8. 获取所有可用的数据源类型
async getDatasourceTypes(): Promise<ApiResponse<DatasourceType[]>> {
const response = await axios.get<ApiResponse<DatasourceType[]>>(`${API_BASE_URL}/types`);
return response.data;
}
}

export default new DatasourceService();
56 changes: 56 additions & 0 deletions data-agent-management/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,62 @@
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<!-- Hive JDBC 驱动 -->
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>3.1.3</version>
<scope>runtime</scope>
<exclusions>
<!-- 排除 Jetty 相关依赖,避免与 Tomcat 冲突 -->
<exclusion>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>*</artifactId>
</exclusion>
<!-- 排除 Hadoop 相关依赖,减少依赖体积 -->
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>*</artifactId>
</exclusion>
<!-- 排除日志相关依赖,使用项目统一的日志框架 -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>*</artifactId>
</exclusion>
<!-- 排除 Tomcat 相关依赖,避免版本冲突 -->
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>*</artifactId>
</exclusion>
<!-- 排除 Servlet API,使用 Spring Boot 提供的版本 -->
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.servlet</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Swagger/OpenAPI 3 with WebFlux (no MVC) -->
<dependency>
<groupId>org.springdoc</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2024-2026 the original author or authors.
*
* Licensed 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
*
* https://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.
*/
package com.alibaba.cloud.ai.dataagent.connector.impls.hive;

import com.alibaba.cloud.ai.dataagent.connector.accessor.AbstractAccessor;
import com.alibaba.cloud.ai.dataagent.connector.ddl.DdlFactory;
import com.alibaba.cloud.ai.dataagent.connector.pool.DBConnectionPoolFactory;
import com.alibaba.cloud.ai.dataagent.enums.BizDataSourceTypeEnum;
import org.springframework.stereotype.Service;

/**
* Hive 数据源访问器实现
*/
@Service("hiveAccessor")
public class HiveDBAccessor extends AbstractAccessor {

private final static String ACCESSOR_TYPE = "Hive_Accessor";

protected HiveDBAccessor(DdlFactory ddlFactory, DBConnectionPoolFactory poolFactory) {
super(ddlFactory, poolFactory.getPoolByDbType(BizDataSourceTypeEnum.HIVE.getTypeName()));
}

@Override
public String getAccessorType() {
return ACCESSOR_TYPE;
}

@Override
public boolean supportedDataSourceType(String type) {
return BizDataSourceTypeEnum.HIVE.getTypeName().equalsIgnoreCase(type);
}

}
Loading
Loading