[fix][chat]Fix TERM schema element not mapped.

This commit is contained in:
jerryjzhang
2024-10-30 22:34:46 +08:00
parent 858feb9c3c
commit adde7bbd45
3 changed files with 22 additions and 14 deletions

View File

@@ -30,6 +30,10 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static com.tencent.supersonic.headless.api.pojo.SchemaElementType.TERM;
import static com.tencent.supersonic.headless.chat.query.rule.QueryMatchOption.OptionType.OPTIONAL;
import static com.tencent.supersonic.headless.chat.query.rule.QueryMatchOption.RequireNumberType.AT_LEAST;
@Slf4j
@ToString
public abstract class RuleSemanticQuery extends BaseSemanticQuery {
@@ -38,6 +42,7 @@ public abstract class RuleSemanticQuery extends BaseSemanticQuery {
public RuleSemanticQuery() {
QueryManager.register(this);
queryMatcher.addOption(TERM, OPTIONAL, AT_LEAST, 0);
}
public List<SchemaElementMatch> match(List<SchemaElementMatch> candidateElementMatches,

View File

@@ -48,6 +48,14 @@ import com.tencent.supersonic.headless.server.service.ModelRelaService;
import com.tencent.supersonic.headless.server.service.ModelService;
import com.tencent.supersonic.headless.server.utils.ModelConverter;
import com.tencent.supersonic.headless.server.utils.NameCheckUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -65,13 +73,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@Service
@Slf4j
@@ -103,8 +104,8 @@ public class ModelServiceImpl implements ModelService {
public ModelServiceImpl(ModelRepository modelRepository, DatabaseService databaseService,
@Lazy DimensionService dimensionService, @Lazy MetricService metricService,
DomainService domainService, UserService userService, DataSetService dataSetService,
DateInfoRepository dateInfoRepository,
ChatModelService chatModelService, ModelRelaService modelRelaService) {
DateInfoRepository dateInfoRepository, ChatModelService chatModelService,
ModelRelaService modelRelaService) {
this.modelRepository = modelRepository;
this.databaseService = databaseService;
this.dimensionService = dimensionService;
@@ -215,9 +216,9 @@ public class ModelServiceImpl implements ModelService {
throws SQLException {
List<DbSchema> dbSchemas = getDbSchemes(modelBuildReq);
Map<String, ModelSchema> modelSchemaMap = new ConcurrentHashMap<>();
CompletableFuture.allOf(dbSchemas.stream()
.map(dbSchema -> CompletableFuture.runAsync(() ->
doBuild(dbSchema, modelSchemaMap), executor))
CompletableFuture.allOf(dbSchemas
.stream().map(dbSchema -> CompletableFuture
.runAsync(() -> doBuild(dbSchema, modelSchemaMap), executor))
.toArray(CompletableFuture[]::new)).join();
return modelSchemaMap;
}

View File

@@ -20,11 +20,13 @@ import com.tencent.supersonic.headless.server.persistence.repository.DateInfoRep
import com.tencent.supersonic.headless.server.persistence.repository.ModelRepository;
import com.tencent.supersonic.headless.server.service.impl.ModelServiceImpl;
import com.tencent.supersonic.headless.server.utils.ModelConverter;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.when;
class ModelServiceImplTest {