mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
Merge branch 'master' of https://github.com/1985312383/supersonic
This commit is contained in:
@@ -5,7 +5,6 @@ import com.tencent.supersonic.headless.api.pojo.DBColumn;
|
||||
import com.tencent.supersonic.headless.api.pojo.enums.FieldType;
|
||||
import com.tencent.supersonic.headless.core.pojo.ConnectInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -148,7 +147,8 @@ public abstract class BaseDbAdaptor implements DbAdaptor {
|
||||
String url = connectionInfo.getUrl().toLowerCase();
|
||||
|
||||
// 设置通用属性
|
||||
properties.setProperty("user", connectionInfo.getUserName());
|
||||
String userName = Optional.ofNullable(connectionInfo.getUserName()).orElse("");
|
||||
properties.setProperty("user", userName);
|
||||
|
||||
|
||||
String password = Optional.ofNullable(connectionInfo.getPassword()).orElse("");
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@Slf4j
|
||||
public class DuckdbAdaptor extends DefaultDbAdaptor {
|
||||
@@ -23,7 +24,7 @@ public class DuckdbAdaptor extends DefaultDbAdaptor {
|
||||
String tableName) throws SQLException {
|
||||
List<DBColumn> dbColumns = Lists.newArrayList();
|
||||
DatabaseMetaData metaData = getDatabaseMetaData(connectInfo);
|
||||
ResultSet columns = metaData.getColumns(schemaName, null, tableName, null);
|
||||
ResultSet columns = metaData.getColumns(null, schemaName, tableName, null);
|
||||
while (columns.next()) {
|
||||
String columnName = columns.getString("COLUMN_NAME");
|
||||
String dataType = columns.getString("TYPE_NAME");
|
||||
@@ -42,4 +43,9 @@ public class DuckdbAdaptor extends DefaultDbAdaptor {
|
||||
return sql.replaceAll("`", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getProperties(ConnectInfo connectionInfo) {
|
||||
return new Properties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class DataModelNode extends SemanticNode {
|
||||
&& !dataModel.getModelDetail().getSqlQuery().isEmpty()) {
|
||||
sqlTable = dataModel.getModelDetail().getSqlQuery();
|
||||
// if model has sqlVariables, parse sqlVariables
|
||||
if (Objects.nonNull(dataModel.getModelDetail().getSqlVariables()) &&
|
||||
!(CollectionUtils.isEmpty(dataModel.getModelDetail().getSqlVariables()))) {
|
||||
if (Objects.nonNull(dataModel.getModelDetail().getSqlVariables())
|
||||
&& !(CollectionUtils.isEmpty(dataModel.getModelDetail().getSqlVariables()))) {
|
||||
sqlTable = SqlVariableParseUtils.parse(sqlTable,
|
||||
dataModel.getModelDetail().getSqlVariables(), Lists.newArrayList());
|
||||
}
|
||||
|
||||
@@ -282,6 +282,7 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
|
||||
public List<DBColumn> getColumns(Long id, String catalog, String db, String table)
|
||||
throws SQLException {
|
||||
DatabaseResp databaseResp = getDatabase(id);
|
||||
catalog = StringUtils.isEmpty(catalog) ? db : catalog;
|
||||
return getColumns(databaseResp, catalog, db, table);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,11 @@ public class ModelConverter {
|
||||
modelDetail.setSqlQuery(modelBuildReq.getSql());
|
||||
} else {
|
||||
modelDetail.setQueryType(ModelDefineType.TABLE_QUERY.getName());
|
||||
modelDetail.setTableQuery(String.format("%s.%s", modelBuildReq.getDb(), tableName));
|
||||
if (modelBuildReq.getDb() != null) {
|
||||
modelDetail.setTableQuery(String.format("%s.%s", modelBuildReq.getDb(), tableName));
|
||||
} else {
|
||||
modelDetail.setTableQuery(tableName);
|
||||
}
|
||||
}
|
||||
List<Field> fields = new ArrayList<>();
|
||||
for (SemanticColumn semanticColumn : modelSchema.getSemanticColumns()) {
|
||||
|
||||
Reference in New Issue
Block a user