feat: add support starrocks and multiple catalog (#2066)

This commit is contained in:
Hyman_bz
2025-02-19 18:00:22 +08:00
committed by GitHub
parent 86b9d2013a
commit 33268bf3d9
12 changed files with 183 additions and 16 deletions

View File

@@ -16,6 +16,7 @@ public class DbParameterFactory {
parametersBuilder.put(EngineType.MYSQL.getName(), new MysqlParametersBuilder());
parametersBuilder.put(EngineType.POSTGRESQL.getName(), new PostgresqlParametersBuilder());
parametersBuilder.put(EngineType.HANADB.getName(), new HanadbParametersBuilder());
parametersBuilder.put(EngineType.STARROCKS.getName(), new StarrocksParametersBuilder());
parametersBuilder.put(EngineType.OTHER.getName(), new OtherParametersBuilder());
}

View File

@@ -0,0 +1,16 @@
package com.tencent.supersonic.headless.server.pojo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class StarrocksParametersBuilder extends DefaultParametersBuilder {
@Override
public List<DatabaseParameter> build() {
return super.build();
}
}

View File

@@ -76,9 +76,15 @@ public class DatabaseController {
return databaseService.executeSql(sqlExecuteReq, user);
}
@RequestMapping("/getCatalogs")
public List<String> getCatalogs(@RequestParam("id") Long databaseId) throws SQLException {
return databaseService.getCatalogs(databaseId);
}
@RequestMapping("/getDbNames")
public List<String> getDbNames(@RequestParam("id") Long databaseId) throws SQLException {
return databaseService.getDbNames(databaseId);
public List<String> getDbNames(@RequestParam("id") Long databaseId,
@RequestParam(value = "catalog", required = false) String catalog) throws SQLException {
return databaseService.getDbNames(databaseId, catalog);
}
@RequestMapping("/getTables")

View File

@@ -36,7 +36,9 @@ public interface DatabaseService {
void deleteDatabase(Long databaseId);
List<String> getDbNames(Long id) throws SQLException;
List<String> getCatalogs(Long id) throws SQLException;
List<String> getDbNames(Long id, String catalog) throws SQLException;
List<String> getTables(Long id, String db) throws SQLException;

View File

@@ -200,10 +200,17 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
}
@Override
public List<String> getDbNames(Long id) throws SQLException {
public List<String> getCatalogs(Long id) throws SQLException {
DatabaseResp databaseResp = getDatabase(id);
DbAdaptor dbAdaptor = DbAdaptorFactory.getEngineAdaptor(databaseResp.getType());
return dbAdaptor.getDBs(DatabaseConverter.getConnectInfo(databaseResp));
return dbAdaptor.getCatalogs(DatabaseConverter.getConnectInfo(databaseResp));
}
@Override
public List<String> getDbNames(Long id, String catalog) throws SQLException {
DatabaseResp databaseResp = getDatabase(id);
DbAdaptor dbAdaptor = DbAdaptorFactory.getEngineAdaptor(databaseResp.getType());
return dbAdaptor.getDBs(DatabaseConverter.getConnectInfo(databaseResp), catalog);
}
@Override