feat:Support kyuubi presto trino (#2109)

This commit is contained in:
zyclove
2025-02-26 17:33:14 +08:00
committed by GitHub
parent 11ff99cdbe
commit 5e3bafb953
31 changed files with 501 additions and 101 deletions

View File

@@ -17,6 +17,9 @@ public class DbParameterFactory {
parametersBuilder.put(EngineType.POSTGRESQL.getName(), new PostgresqlParametersBuilder());
parametersBuilder.put(EngineType.HANADB.getName(), new HanadbParametersBuilder());
parametersBuilder.put(EngineType.STARROCKS.getName(), new StarrocksParametersBuilder());
parametersBuilder.put(EngineType.KYUUBI.getName(), new KyuubiParametersBuilder());
parametersBuilder.put(EngineType.PRESTO.getName(), new PrestoParametersBuilder());
parametersBuilder.put(EngineType.TRINO.getName(), new TrinoParametersBuilder());
parametersBuilder.put(EngineType.OTHER.getName(), new OtherParametersBuilder());
}

View File

@@ -29,6 +29,7 @@ public class DefaultParametersBuilder implements DbParametersBuilder {
password.setComment("密码");
password.setName("password");
password.setPlaceholder("请输入密码");
password.setRequire(false);
databaseParameters.add(password);
return databaseParameters;

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 KyuubiParametersBuilder extends DefaultParametersBuilder {
@Override
public List<DatabaseParameter> build() {
return super.build();
}
}

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 PrestoParametersBuilder extends DefaultParametersBuilder {
@Override
public List<DatabaseParameter> build() {
return super.build();
}
}

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 TrinoParametersBuilder extends DefaultParametersBuilder {
@Override
public List<DatabaseParameter> build() {
return super.build();
}
}

View File

@@ -89,15 +89,18 @@ public class DatabaseController {
@RequestMapping("/getTables")
public List<String> getTables(@RequestParam("databaseId") Long databaseId,
@RequestParam(value = "catalog", required = false) String catalog,
@RequestParam("db") String db) throws SQLException {
return databaseService.getTables(databaseId, db);
return databaseService.getTables(databaseId, catalog, db);
}
@RequestMapping("/getColumnsByName")
public List<DBColumn> getColumnsByName(@RequestParam("databaseId") Long databaseId,
@RequestParam("db") String db, @RequestParam("table") String table)
@RequestParam(name="catalog", required = false) String catalog,
@RequestParam("db") String db,
@RequestParam("table") String table)
throws SQLException {
return databaseService.getColumns(databaseId, db, table);
return databaseService.getColumns(databaseId, catalog, db, table);
}
@PostMapping("/listColumnsBySql")

View File

@@ -40,11 +40,11 @@ public interface DatabaseService {
List<String> getDbNames(Long id, String catalog) throws SQLException;
List<String> getTables(Long id, String db) throws SQLException;
List<String> getTables(Long id, String catalog, String db) throws SQLException;
Map<String, List<DBColumn>> getDbColumns(ModelBuildReq modelBuildReq) throws SQLException;
List<DBColumn> getColumns(Long id, String db, String table) throws SQLException;
List<DBColumn> getColumns(Long id, String catalog, String db, String table) throws SQLException;
List<DBColumn> getColumns(Long id, String sql) throws SQLException;
}

View File

@@ -214,10 +214,10 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
}
@Override
public List<String> getTables(Long id, String db) throws SQLException {
public List<String> getTables(Long id, String catalog, String db) throws SQLException {
DatabaseResp databaseResp = getDatabase(id);
DbAdaptor dbAdaptor = DbAdaptorFactory.getEngineAdaptor(databaseResp.getType());
return dbAdaptor.getTables(DatabaseConverter.getConnectInfo(databaseResp), db);
return dbAdaptor.getTables(DatabaseConverter.getConnectInfo(databaseResp), catalog, db);
}
@Override
@@ -234,7 +234,7 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
} else {
for (String table : modelBuildReq.getTables()) {
List<DBColumn> columns =
getColumns(modelBuildReq.getDatabaseId(), modelBuildReq.getDb(), table);
getColumns(modelBuildReq.getDatabaseId(), modelBuildReq.getCatalog(), modelBuildReq.getDb(), table);
dbColumnMap.put(table, columns);
}
}
@@ -242,15 +242,15 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
}
@Override
public List<DBColumn> getColumns(Long id, String db, String table) throws SQLException {
public List<DBColumn> getColumns(Long id, String catalog, String db, String table) throws SQLException {
DatabaseResp databaseResp = getDatabase(id);
return getColumns(databaseResp, db, table);
return getColumns(databaseResp, catalog, db, table);
}
public List<DBColumn> getColumns(DatabaseResp databaseResp, String db, String table)
public List<DBColumn> getColumns(DatabaseResp databaseResp, String catalog, String db, String table)
throws SQLException {
DbAdaptor engineAdaptor = DbAdaptorFactory.getEngineAdaptor(databaseResp.getType());
return engineAdaptor.getColumns(DatabaseConverter.getConnectInfo(databaseResp), db, table);
return engineAdaptor.getColumns(DatabaseConverter.getConnectInfo(databaseResp), catalog, db, table);
}
@Override