mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(headless)Modify text2sql prompts to remove dependency on datediff, thus avoiding SQL compatibility issues. #1391
This commit is contained in:
@@ -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:";
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user