[fix][headless]Fix expr conversion issue.
Some checks failed
supersonic CentOS CI / build (21) (push) Has been cancelled
supersonic mac CI / build (21) (push) Has been cancelled
supersonic ubuntu CI / build (21) (push) Has been cancelled
supersonic windows CI / build (21) (push) Has been cancelled

This commit is contained in:
jerryjzhang
2025-01-17 20:43:05 +08:00
parent 416488b919
commit 65f0096724
4 changed files with 11 additions and 15 deletions

View File

@@ -21,6 +21,6 @@ public class DbAdaptorFactory {
} }
public static DbAdaptor getEngineAdaptor(String engineType) { public static DbAdaptor getEngineAdaptor(String engineType) {
return dbAdaptorMap.get(engineType); return dbAdaptorMap.get(engineType.toUpperCase());
} }
} }

View File

@@ -26,8 +26,7 @@ public class DbDialectOptimizer implements QueryOptimizer {
SemanticSchemaResp semanticSchemaResp = queryStatement.getSemanticSchema(); SemanticSchemaResp semanticSchemaResp = queryStatement.getSemanticSchema();
DatabaseResp database = semanticSchemaResp.getDatabaseResp(); DatabaseResp database = semanticSchemaResp.getDatabaseResp();
String sql = queryStatement.getSql(); String sql = queryStatement.getSql();
DbAdaptor engineAdaptor = DbAdaptor engineAdaptor = DbAdaptorFactory.getEngineAdaptor(database.getType());
DbAdaptorFactory.getEngineAdaptor(database.getType().toLowerCase());
if (Objects.nonNull(engineAdaptor)) { if (Objects.nonNull(engineAdaptor)) {
String adaptedSql = engineAdaptor.rewriteSql(sql); String adaptedSql = engineAdaptor.rewriteSql(sql);
queryStatement.setSql(adaptedSql); queryStatement.setSql(adaptedSql);

View File

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

View File

@@ -271,26 +271,24 @@ public class ModelConverter {
if (measures != null) { if (measures != null) {
for (Measure measure : measures) { for (Measure measure : measures) {
if (StringUtils.isBlank(measure.getBizName())) { if (StringUtils.isNotBlank(measure.getBizName())
continue; && StringUtils.isBlank(measure.getExpr())) {
}
measure.setExpr(measure.getBizName()); measure.setExpr(measure.getBizName());
} }
} }
}
if (dimensions != null) { if (dimensions != null) {
for (Dimension dimension : dimensions) { for (Dimension dimension : dimensions) {
if (StringUtils.isBlank(dimension.getBizName())) { if (StringUtils.isNotBlank(dimension.getBizName())
continue; && StringUtils.isBlank(dimension.getExpr())) {
}
dimension.setExpr(dimension.getBizName()); dimension.setExpr(dimension.getBizName());
} }
} }
}
if (identifiers != null) { if (identifiers != null) {
for (Identify identify : identifiers) { for (Identify identify : identifiers) {
if (StringUtils.isBlank(identify.getBizName())) { if (StringUtils.isNotBlank(identify.getBizName())
continue; && StringUtils.isBlank(identify.getName())) {
}
if (StringUtils.isBlank(identify.getName())) {
identify.setName(identify.getBizName()); identify.setName(identify.getBizName());
} }
identify.setIsCreateDimension(1); identify.setIsCreateDimension(1);