mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 22:25:19 +00:00
feat: add support starrocks and multiple catalog (#2066)
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user