You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.Add parameter: GENERATE_SQL_QUERY_LIMIT_ENABLED (default value is True to control data return Limit 1000 rows)
2.Use different SQL example templates based on different data sources.
SELECT user, status FROM PUBLIC.USERS -- 错误:未处理关键字和引号
61
+
SELECT "user", ROUND(active_ratio) FROM "PUBLIC"."USERS" -- 错误:百分比格式错误
62
+
</output-bad>
63
+
<output-good>
64
+
SELECT
65
+
"u"."user" AS "user_account",
66
+
CONCAT(ROUND("u"."active_ratio" * 100, 2), '%') AS "active_percent"
67
+
FROM "PUBLIC"."USERS" "u"
68
+
WHERE "u"."status" = 1
69
+
FETCH FIRST 1000 ROWS ONLY
70
+
</output-good>
71
+
</example>
72
+
</basic-examples>
73
+
74
+
example_engine: AWS Redshift 1.0
75
+
example_answer_1: |
76
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"continent\" AS \"continent_name\", \"year\" AS \"year\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" ORDER BY \"country\", \"year\"","tables":["sample_country_gdp"],"chart-type":"line"}
77
+
example_answer_1_with_limit: |
78
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"continent\" AS \"continent_name\", \"year\" AS \"year\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" ORDER BY \"country\", \"year\" LIMIT 1000 OFFSET 0","tables":["sample_country_gdp"],"chart-type":"line"}
79
+
example_answer_2: |
80
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2024' ORDER BY \"gdp\" DESC","tables":["sample_country_gdp"],"chart-type":"pie"}
81
+
example_answer_2_with_limit: |
82
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2024' ORDER BY \"gdp\" DESC LIMIT 1000 OFFSET 0","tables":["sample_country_gdp"],"chart-type":"pie"}
83
+
example_answer_3: |
84
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2025' AND \"country\" = '中国'","tables":["sample_country_gdp"],"chart-type":"table"}
85
+
example_answer_3_with_limit: |
86
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2025' AND \"country\" = '中国' LIMIT 1000 OFFSET 0","tables":["sample_country_gdp"],"chart-type":"table"}
SELECT * FROM default.events LIMIT 100 -- 错误1:使用星号
44
+
SELECT message FROM "default"."events" WHERE level = 'error' -- 错误2:未处理JSON字段
45
+
SELECT "message", "extra.error_code" FROM events LIMIT 100 -- 错误3:表名未加引号
46
+
</output-bad>
47
+
<output-good>
48
+
SELECT
49
+
"e"."message" AS "log_content",
50
+
"e"."extra"."error_code" AS "error_id",
51
+
toDateTime("e"."timestamp") AS "log_time"
52
+
FROM "default"."events" "e"
53
+
WHERE "e"."level" = 'error'
54
+
LIMIT 100
55
+
</output-good>
56
+
</example>
57
+
58
+
<example>
59
+
<input>统计各地区的错误率Top 5(含百分比)</input>
60
+
<output-bad>
61
+
SELECT region, COUNT(*) FROM events GROUP BY region -- 错误1:使用COUNT(*)
62
+
SELECT "region", MAX("count") FROM "events" GROUP BY 1 -- 错误2:使用序号分组
63
+
</output-bad>
64
+
<output-good>
65
+
SELECT
66
+
"e"."region" AS "area",
67
+
COUNT(*) AS "total",
68
+
COUNTIf("e"."level" = 'error') AS "error_count",
69
+
ROUND(error_count * 100.0 / total, 2) || '%' AS "error_rate"
70
+
FROM "default"."events" "e"
71
+
GROUP BY "e"."region"
72
+
ORDER BY "error_rate" DESC
73
+
LIMIT 5
74
+
</output-good>
75
+
</example>
76
+
</basic-examples>
77
+
78
+
example_engine: ClickHouse 23.3
79
+
example_answer_1: |
80
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"continent\" AS \"continent_name\", \"year\" AS \"year\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" ORDER BY \"country\", \"year\"","tables":["sample_country_gdp"],"chart-type":"line"}
81
+
example_answer_1_with_limit: |
82
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"continent\" AS \"continent_name\", \"year\" AS \"year\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" ORDER BY \"country\", \"year\" LIMIT 1000","tables":["sample_country_gdp"],"chart-type":"line"}
83
+
example_answer_2: |
84
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2024' ORDER BY \"gdp\" DESC","tables":["sample_country_gdp"],"chart-type":"pie"}
85
+
example_answer_2_with_limit: |
86
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2024' ORDER BY \"gdp\" DESC LIMIT 1000","tables":["sample_country_gdp"],"chart-type":"pie"}
87
+
example_answer_3: |
88
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2025' AND \"country\" = '中国'","tables":["sample_country_gdp"],"chart-type":"table"}
89
+
example_answer_3_with_limit: |
90
+
{"success":true,"sql":"SELECT \"country\" AS \"country_name\", \"gdp\" AS \"gdp_usd\" FROM \"Sample_Database\".\"sample_country_gdp\" WHERE \"year\" = '2025' AND \"country\" = '中国' LIMIT 1000","tables":["sample_country_gdp"],"chart-type":"table"}
0 commit comments