[improvement][headless]Opt code format.
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-11 09:25:27 +08:00
parent 715adb5260
commit 329756056c
4 changed files with 11 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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