mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-20 06:34:55 +00:00
[fix][chat]Fix logic in s2sql parsing.
This commit is contained in:
@@ -108,6 +108,7 @@ public class Text2SQLEval extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SetSystemProperty(key = "s2.test", value = "true")
|
||||
public void test_filter_and_top() throws Exception {
|
||||
long start = System.currentTimeMillis();
|
||||
QueryResult result = submitNewChat("近半个月来marketing部门访问量最高的用户是谁", agent.getId());
|
||||
|
||||
@@ -10,17 +10,21 @@ import com.tencent.supersonic.common.pojo.Order;
|
||||
import com.tencent.supersonic.common.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.headless.api.pojo.SemanticSchema;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QuerySqlReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QueryStructReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.SemanticQueryReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
|
||||
import com.tencent.supersonic.headless.server.facade.service.SemanticLayerService;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.DomainDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.repository.DomainRepository;
|
||||
import com.tencent.supersonic.headless.server.service.DatabaseService;
|
||||
import com.tencent.supersonic.headless.server.service.SchemaService;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -40,9 +44,12 @@ public class BaseTest extends BaseApplication {
|
||||
protected SchemaService schemaService;
|
||||
@Autowired
|
||||
private AgentService agentService;
|
||||
@Autowired
|
||||
protected DatabaseService databaseService;
|
||||
|
||||
protected Agent agent;
|
||||
protected SemanticSchema schema;
|
||||
protected DatabaseResp databaseResp;
|
||||
|
||||
protected Agent getAgentByName(String agentName) {
|
||||
Optional<Agent> agent = agentService.getAgents().stream()
|
||||
@@ -59,6 +66,16 @@ public class BaseTest extends BaseApplication {
|
||||
return semanticLayerService.queryByReq(buildQuerySqlReq(sql), user);
|
||||
}
|
||||
|
||||
protected void executeSql(String sql) {
|
||||
if (databaseResp == null) {
|
||||
databaseResp = databaseService.getDatabase(1L);
|
||||
}
|
||||
SemanticQueryResp queryResp = databaseService.executeSql(sql, databaseResp);
|
||||
assert StringUtils.isBlank(queryResp.getErrorMsg());
|
||||
System.out.println(
|
||||
String.format("Execute result: %s", JsonUtil.toString(queryResp.getResultList())));
|
||||
}
|
||||
|
||||
protected SemanticQueryReq buildQuerySqlReq(String sql) {
|
||||
QuerySqlReq querySqlCmd = new QuerySqlReq();
|
||||
querySqlCmd.setSql(sql);
|
||||
|
||||
Reference in New Issue
Block a user