(fix)(headless)Add null handling to avoid NPEs.
Some checks are pending
supersonic CentOS CI / build (21) (push) Waiting to run
supersonic mac CI / build (21) (push) Waiting to run
supersonic ubuntu CI / build (21) (push) Waiting to run
supersonic windows CI / build (21) (push) Waiting to run

This commit is contained in:
supersonicbi
2025-06-15 15:15:54 +08:00
parent 303392f492
commit 96855e7933
5 changed files with 14 additions and 8 deletions

View File

@@ -71,8 +71,9 @@ public class MemoryServiceImpl implements MemoryService, CommandLineRunner {
chatMemoryDO.setS2sql(chatMemoryUpdateReq.getS2sql());
chatMemoryDO.setDbSchema(chatMemoryUpdateReq.getDbSchema());
enableMemory(chatMemoryDO);
} else if ((MemoryStatus.DISABLED.equals(chatMemoryUpdateReq.getStatus())||MemoryStatus.PENDING.equals(chatMemoryUpdateReq.getStatus())) && hadEnabled) {
// Remove from vector DB when transitioning: launched→disabled OR enabled→pending
} else if ((MemoryStatus.DISABLED.equals(chatMemoryUpdateReq.getStatus())
|| MemoryStatus.PENDING.equals(chatMemoryUpdateReq.getStatus())) && hadEnabled) {
// Remove from vector DB when transitioning: launched→disabled OR enabled→pending
disableMemory(chatMemoryDO);
}
LambdaUpdateWrapper<ChatMemoryDO> updateWrapper = new LambdaUpdateWrapper<>();

View File

@@ -52,7 +52,8 @@ public class PromptHelper {
for (int i = 0; i < selfConsistencyNumber; i++) {
List<Text2SQLExemplar> shuffledList = new ArrayList<>(exemplars);
// only shuffle the exemplars from config
List<Text2SQLExemplar> subList=shuffledList.subList(llmReq.getDynamicExemplars().size(),shuffledList.size());
List<Text2SQLExemplar> subList =
shuffledList.subList(llmReq.getDynamicExemplars().size(), shuffledList.size());
Collections.shuffle(subList);
results.add(shuffledList.subList(0, Math.min(shuffledList.size(), fewShotNumber)));
}

View File

@@ -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("");

View File

@@ -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());
}

View File

@@ -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()) {