(improvement)(headless)Modify text2sql prompts to remove dependency on datediff, thus avoiding SQL compatibility issues. #1391

This commit is contained in:
jerryjzhang
2024-07-10 19:49:38 +08:00
parent 03f5678732
commit 78a91ad8c2
4 changed files with 25 additions and 158 deletions

View File

@@ -27,13 +27,13 @@ public class OnePassSCSqlGenStrategy extends SqlGenStrategy {
private static final String INSTRUCTION = ""
+ "#Role: You are a data analyst experienced in SQL languages.\n"
+ "#Task: You will be provided a natural language query asked by business users,"
+ "please convert it to a SQL query so that relevant answer could be returned to the user "
+ "#Task: You will be provided a natural language question asked by users,"
+ "please convert it to a SQL query so that relevant data could be returned to the user "
+ "by executing the SQL query against underlying database.\n"
+ "#Rules:"
+ "1.ALWAYS use `数据日期` as the date field."
+ "2.ALWAYS use `datediff()` as the date function."
+ "3.DO NOT specify date filter in the where clause if not explicitly mentioned in the query."
+ "2.ALWAYS specify date filter using `>`,`<`,`>=`,`<=` operator."
+ "3.DO NOT include date filter in the where clause if not explicitly expressed in the query."
+ "4.ONLY respond with the converted SQL statement.\n"
+ "#Exemplars:\n{{exemplar}}"
+ "#Question:{{question}} #Schema:{{schema}} #SQL:";

View File

@@ -56,10 +56,7 @@ public class ParseInfoProcessor implements ResultProcessor {
if (StringUtils.isBlank(correctS2SQL)) {
return;
}
// if S2SQL equals correctS2SQL, then not update the parseInfo.
if (correctS2SQL.equals(sqlInfo.getParsedS2SQL())) {
return;
}
List<FieldExpression> expressions = SqlSelectHelper.getFilterExpression(correctS2SQL);
//set dataInfo
try {