mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
[improvement][headless]Opt code format.
This commit is contained in:
@@ -32,8 +32,7 @@ public class LLMSqlCorrector extends BaseSemanticCorrector {
|
||||
private static final String INSTRUCTION = ""
|
||||
+ "#Role: You are a senior data engineer experienced in writing SQL."
|
||||
+ "\n#Task: Your will be provided with a user question and the SQL written by a junior engineer,"
|
||||
+ "please take a review and help correct it if necessary."
|
||||
+ "\n#Rules: "
|
||||
+ "please take a review and help correct it if necessary." + "\n#Rules: "
|
||||
+ "1.ALWAYS specify time range using `>`,`<`,`>=`,`<=` operator."
|
||||
+ "2.DO NOT calculate date range using functions."
|
||||
+ "3.SQL columns and values must be mentioned in the `#Schema`."
|
||||
@@ -77,7 +76,8 @@ public class LLMSqlCorrector extends BaseSemanticCorrector {
|
||||
semanticParseInfo, chatApp.getPrompt(), exemplar);
|
||||
SemanticSql s2Sql = extractor.generateSemanticSql(prompt.toUserMessage().singleText());
|
||||
keyPipelineLog.info("LLMSqlCorrector modelReq:\n{} \nmodelResp:\n{}", prompt.text(), s2Sql);
|
||||
if ("NEGATIVE".equalsIgnoreCase(s2Sql.getOpinion()) && StringUtils.isNotBlank(s2Sql.getSql())) {
|
||||
if ("NEGATIVE".equalsIgnoreCase(s2Sql.getOpinion())
|
||||
&& StringUtils.isNotBlank(s2Sql.getSql())) {
|
||||
semanticParseInfo.getSqlInfo().setCorrectedS2SQL(s2Sql.getSql());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ public abstract class SqlGenStrategy implements InitializingBean {
|
||||
return ModelProvider.getChatModel(modelConfig);
|
||||
}
|
||||
|
||||
abstract LLMResp generate(LLMReq llmReq);
|
||||
public abstract LLMResp generate(LLMReq llmReq);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ public class SqlQueryParser implements QueryParser {
|
||||
List<String> semanticFields = Lists.newArrayList();
|
||||
ontologyQuery.getMetrics().forEach(m -> semanticFields.add(m.getName()));
|
||||
ontologyQuery.getDimensions().forEach(d -> semanticFields.add(d.getName()));
|
||||
String errMsg = String.format("Querying columns[%s] not matched with semantic fields[%s].",
|
||||
String errMsg =
|
||||
String.format("Querying columns[%s] not matched with semantic fields[%s].",
|
||||
queryFields, semanticFields);
|
||||
queryStatement.setErrMsg(errMsg);
|
||||
queryStatement.setStatus(QueryState.INVALID);
|
||||
|
||||
@@ -119,16 +119,11 @@ public class QueryUtils {
|
||||
if (StringUtils.isBlank(type)) {
|
||||
return false;
|
||||
}
|
||||
return type.equalsIgnoreCase("int")
|
||||
|| type.equalsIgnoreCase("bigint")
|
||||
|| type.equalsIgnoreCase("tinyint")
|
||||
|| type.equalsIgnoreCase("smallint")
|
||||
|| type.equalsIgnoreCase("float")
|
||||
|| type.equalsIgnoreCase("double")
|
||||
|| type.equalsIgnoreCase("real")
|
||||
|| type.equalsIgnoreCase("numeric")
|
||||
|| type.toLowerCase().startsWith("decimal")
|
||||
|| type.toLowerCase().startsWith("uint")
|
||||
return type.equalsIgnoreCase("int") || type.equalsIgnoreCase("bigint")
|
||||
|| type.equalsIgnoreCase("tinyint") || type.equalsIgnoreCase("smallint")
|
||||
|| type.equalsIgnoreCase("float") || type.equalsIgnoreCase("double")
|
||||
|| type.equalsIgnoreCase("real") || type.equalsIgnoreCase("numeric")
|
||||
|| type.toLowerCase().startsWith("decimal") || type.toLowerCase().startsWith("uint")
|
||||
|| type.toLowerCase().startsWith("int");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user